Skip to content

Commit 88733d2

Browse files
committed
Type-safe fake-zone names
1 parent 2daabf5 commit 88733d2

File tree

1 file changed

+28
-42
lines changed

1 file changed

+28
-42
lines changed

nexus/reconfigurator/planning/src/planner.rs

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4532,6 +4532,20 @@ pub(crate) mod test {
45324532
example.system.to_collection_builder().unwrap().build();
45334533
}
45344534

4535+
macro_rules! fake_zone_artifact {
4536+
($kind: ident, $version: expr) => {
4537+
TufArtifactMeta {
4538+
id: ArtifactId {
4539+
name: ZoneKind::$kind.artifact_name().to_string(),
4540+
version: $version,
4541+
kind: ArtifactKind::from_known(KnownArtifactKind::Zone),
4542+
},
4543+
hash: ArtifactHash([0; 32]),
4544+
size: 0,
4545+
}
4546+
};
4547+
}
4548+
45354549
#[test]
45364550
fn test_update_crucible_pantry() {
45374551
static TEST_NAME: &str = "update_crucible_pantry";
@@ -4616,24 +4630,8 @@ pub(crate) mod test {
46164630
hash: fake_hash,
46174631
};
46184632
let artifacts = vec![
4619-
TufArtifactMeta {
4620-
id: ArtifactId {
4621-
name: String::from("crucible-pantry-zone"),
4622-
version: version.clone(),
4623-
kind: ArtifactKind::from_known(KnownArtifactKind::Zone),
4624-
},
4625-
hash: fake_hash,
4626-
size: 0,
4627-
},
4628-
TufArtifactMeta {
4629-
id: ArtifactId {
4630-
name: String::from("nexus"),
4631-
version: version.clone(),
4632-
kind: ArtifactKind::from_known(KnownArtifactKind::Zone),
4633-
},
4634-
hash: fake_hash,
4635-
size: 0,
4636-
},
4633+
fake_zone_artifact!(CruciblePantry, version.clone()),
4634+
fake_zone_artifact!(Nexus, version.clone()),
46374635
];
46384636
input_builder.policy_mut().tuf_repo = Some(TufRepoDescription {
46394637
repo: TufRepoMeta {
@@ -4845,19 +4843,6 @@ pub(crate) mod test {
48454843
},
48464844
hash: fake_hash,
48474845
};
4848-
macro_rules! zone_artifact {
4849-
($name:expr) => {
4850-
TufArtifactMeta {
4851-
id: ArtifactId {
4852-
name: String::from($name),
4853-
version: version.clone(),
4854-
kind: ArtifactKind::from_known(KnownArtifactKind::Zone),
4855-
},
4856-
hash: fake_hash,
4857-
size: 0,
4858-
}
4859-
};
4860-
}
48614846
let tuf_repo = TufRepoDescription {
48624847
repo: TufRepoMeta {
48634848
hash: fake_hash,
@@ -4867,17 +4852,18 @@ pub(crate) mod test {
48674852
file_name: String::from(""),
48684853
},
48694854
artifacts: vec![
4870-
zone_artifact!("ntp"),
4871-
zone_artifact!("clickhouse"),
4872-
zone_artifact!("clickhouse_keeper"),
4873-
zone_artifact!("cockroachdb"),
4874-
zone_artifact!("crucible-zone"),
4875-
zone_artifact!("crucible-pantry-zone"),
4876-
zone_artifact!("external-dns"),
4877-
zone_artifact!("internal-dns"),
4878-
zone_artifact!("ntp"),
4879-
zone_artifact!("nexus"),
4880-
zone_artifact!("oximeter"),
4855+
fake_zone_artifact!(BoundaryNtp, version.clone()),
4856+
fake_zone_artifact!(Clickhouse, version.clone()),
4857+
fake_zone_artifact!(ClickhouseKeeper, version.clone()),
4858+
fake_zone_artifact!(ClickhouseServer, version.clone()),
4859+
fake_zone_artifact!(CockroachDb, version.clone()),
4860+
fake_zone_artifact!(Crucible, version.clone()),
4861+
fake_zone_artifact!(CruciblePantry, version.clone()),
4862+
fake_zone_artifact!(ExternalDns, version.clone()),
4863+
fake_zone_artifact!(InternalDns, version.clone()),
4864+
fake_zone_artifact!(InternalNtp, version.clone()),
4865+
fake_zone_artifact!(Nexus, version.clone()),
4866+
fake_zone_artifact!(Oximeter, version.clone()),
48814867
],
48824868
};
48834869
input_builder.policy_mut().tuf_repo = Some(tuf_repo);

0 commit comments

Comments
 (0)