Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ hubtools = { git = "https://github.com/oxidecomputer/hubtools.git", branch = "ma
humantime = "2.1.0"
indent_write = "2.2.0"
itertools = "0.13.0"
parse-display = "0.10.0"
parse-size = "1.1.0"
predicates = "3.1.3"
proptest = "1.5.0"
Expand Down
1 change: 0 additions & 1 deletion artifact/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ schemars = ["dep:schemars"]
[dependencies]
daft.workspace = true
hex.workspace = true
parse-display.workspace = true
proptest = { workspace = true, optional = true }
schemars = { workspace = true, optional = true }
semver.workspace = true
Expand Down
14 changes: 14 additions & 0 deletions artifact/src/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,17 @@ fn hex_schema<const N: usize>(
schema.format = Some(format!("hex string ({N} bytes)"));
schema.into()
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn display_respects_padding() {
let h = ArtifactHash([0; 32]);
assert_eq!(
format!("{h:x>100}"),
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0000000000000000000000000000000000000000000000000000000000000000"
);
}
}
16 changes: 12 additions & 4 deletions artifact/src/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
use std::{borrow::Cow, convert::Infallible, fmt, str::FromStr};

use daft::Diffable;
use parse_display::{Display, FromStr};
use serde::{Deserialize, Serialize};
use strum::{EnumIter, IntoEnumIterator};
use strum::{Display, EnumIter, EnumString, IntoEnumIterator};
use thiserror::Error;

/// The kind of artifact we are dealing with.
Expand Down Expand Up @@ -168,13 +167,13 @@ impl FromStr for ArtifactKind {
Ord,
PartialOrd,
Display,
FromStr,
EnumString,
Deserialize,
Serialize,
EnumIter,
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[display(style = "snake_case")]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum KnownArtifactKind {
// Sled Artifacts
Expand Down Expand Up @@ -289,4 +288,13 @@ mod tests {
assert_eq!(kind, kind2);
}
}

#[test]
fn display_respects_padding() {
let kind = ArtifactKind::from_static("foo");
assert_eq!(format!("{kind:x>10}"), "xxxxxxxfoo");

let kind = KnownArtifactKind::Host;
assert_eq!(format!("{kind:x>10}"), "xxxxxxhost");
}
}
6 changes: 6 additions & 0 deletions artifact/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ mod tests {
);
}

#[test]
fn display_respects_padding() {
let v = ArtifactVersion::new_const("5.4.3");
assert_eq!(format!("{v:x>10}"), "xxxxx5.4.3");
}

#[proptest]
fn proptest_valid_version(#[strategy(PROPTEST_REGEX)] version: String) {
validate_version(&version).unwrap();
Expand Down
Loading