Skip to content

Commit

Permalink
lib: Add a unit test for parsing the host CRD
Browse files Browse the repository at this point in the history
Just on general principle; prep for further refactoring.
  • Loading branch information
cgwalters committed Oct 17, 2023
1 parent 0a657ea commit 7562b5c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/src/fixtures/spec.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions lib/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
}
}

0 comments on commit 7562b5c

Please sign in to comment.