Skip to content

Commit 9e0cf70

Browse files
authored
Merge pull request #148 from cgwalters/unit-test-parse-spec
lib: Add a unit test for parsing the host CRD
2 parents 0a657ea + 24919a9 commit 9e0cf70

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

lib/src/fixtures/spec.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: org.containers.bootc/v1alpha1
2+
kind: BootcHost
3+
metadata:
4+
name: host
5+
spec:
6+
image:
7+
image: quay.io/example/someimage:latest
8+
transport: registry
9+
signature: insecure
10+
status:
11+
staged:
12+
image:
13+
image:
14+
image: quay.io/example/someimage:latest
15+
transport: registry
16+
signature: insecure
17+
version: nightly
18+
timestamp: 2023-10-14T19:22:15Z
19+
imageDigest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566
20+
incompatible: false
21+
pinned: false
22+
ostree:
23+
checksum: 3c6dad657109522e0b2e49bf44b5420f16f0b438b5b9357e5132211cfbad135d
24+
deploySerial: 0
25+
booted:
26+
image:
27+
image:
28+
image: quay.io/example/someimage:latest
29+
transport: registry
30+
signature: insecure
31+
version: nightly
32+
timestamp: 2023-09-30T19:22:16Z
33+
imageDigest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34
34+
incompatible: false
35+
pinned: false
36+
ostree:
37+
checksum: 26836632adf6228d64ef07a26fd3efaf177104efd1f341a2cf7909a3e4e2c72c
38+
deploySerial: 0
39+
rollback: null
40+
isContainer: false

lib/src/spec.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,18 @@ pub struct HostStatus {
101101
/// Whether or not the current system state is an ostree-based container
102102
pub is_container: bool,
103103
}
104+
105+
#[cfg(test)]
106+
mod tests {
107+
use super::*;
108+
109+
#[test]
110+
fn test_parse_spec() {
111+
const SPEC_FIXTURE: &str = include_str!("fixtures/spec.yaml");
112+
let host: Host = serde_yaml::from_str(SPEC_FIXTURE).unwrap();
113+
assert_eq!(
114+
host.spec.image.as_ref().unwrap().image.as_str(),
115+
"quay.io/example/someimage:latest"
116+
);
117+
}
118+
}

0 commit comments

Comments
 (0)