diff --git a/lib/src/fixtures/spec.yaml b/lib/src/fixtures/spec.yaml new file mode 100644 index 000000000..6ef439fae --- /dev/null +++ b/lib/src/fixtures/spec.yaml @@ -0,0 +1,40 @@ +apiVersion: org.containers.bootc/v1alpha1 +kind: BootcHost +metadata: + name: host +spec: + image: + image: quay.io/example/someimage:latest + transport: registry + signature: insecure +status: + staged: + image: + image: + image: quay.io/example/someimage:latest + transport: registry + signature: insecure + version: nightly + timestamp: 2023-10-14T19:22:15Z + imageDigest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566 + incompatible: false + pinned: false + ostree: + checksum: 3c6dad657109522e0b2e49bf44b5420f16f0b438b5b9357e5132211cfbad135d + deploySerial: 0 + booted: + image: + image: + image: quay.io/example/someimage:latest + transport: registry + signature: insecure + version: nightly + timestamp: 2023-09-30T19:22:16Z + imageDigest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34 + incompatible: false + pinned: false + ostree: + checksum: 26836632adf6228d64ef07a26fd3efaf177104efd1f341a2cf7909a3e4e2c72c + deploySerial: 0 + rollback: null + isContainer: false diff --git a/lib/src/spec.rs b/lib/src/spec.rs index a7dd2af91..8019a3d6f 100644 --- a/lib/src/spec.rs +++ b/lib/src/spec.rs @@ -101,3 +101,18 @@ pub struct HostStatus { /// Whether or not the current system state is an ostree-based container pub is_container: bool, } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parse_spec() { + const SPEC_FIXTURE: &str = include_str!("fixtures/spec.yaml"); + let host: Host = serde_yaml::from_str(SPEC_FIXTURE).unwrap(); + assert_eq!( + host.spec.image.as_ref().unwrap().image.as_str(), + "quay.io/example/someimage:latest" + ); + } +}