github.com/quay/claircore@v1.5.28/rhel/internal/pulp/manifest_test.go (about) 1 package pulp 2 3 import ( 4 "encoding/hex" 5 "os" 6 "testing" 7 8 "github.com/google/go-cmp/cmp" 9 ) 10 11 func TestManifestLoad(t *testing.T) { 12 unhex := func(s string) []byte { 13 b, err := hex.DecodeString(s) 14 if err != nil { 15 t.Fatal(err) 16 } 17 return b 18 } 19 var want = Manifest{ 20 Entry{ 21 Path: "RHEL8/openshift-4.1.oval.xml.bz2", 22 Checksum: unhex("b067fe8942118b9dfa7ae24569601d1081e63b7050033953c9154324ff55cc27"), 23 Size: 12994, 24 }, 25 Entry{ 26 Path: "RHEL8/openshift-4.2.oval.xml.bz2", 27 Checksum: unhex("b067fe8942118b9dfa7ae24569601d1081e63b7050033953c9154324ff55cc27"), 28 Size: 12994, 29 }, 30 Entry{ 31 Path: "RHEL8/openshift-4.3.oval.xml.bz2", 32 Checksum: unhex("b067fe8942118b9dfa7ae24569601d1081e63b7050033953c9154324ff55cc27"), 33 Size: 12994, 34 }, 35 Entry{ 36 Path: "RHEL8/openshift-4-including-unpatched.oval.xml.bz2", 37 Checksum: unhex("040a8719cf7b2e5726cd96d642cd5fe6d24381cbd92f0caa99a977296b9070dc"), 38 Size: 27469, 39 }, 40 Entry{ 41 Path: "RHEL8/openshift-4.oval.xml.bz2", 42 Checksum: unhex("b067fe8942118b9dfa7ae24569601d1081e63b7050033953c9154324ff55cc27"), 43 Size: 12994, 44 }, 45 Entry{ 46 Path: "RHEL8/openshift-service-mesh-1.0.oval.xml.bz2", 47 Checksum: unhex("901b29d7928f55cf1b09928b75f2d6199ce8741c07a79bd010eca23d3fa85155"), 48 Size: 5364, 49 }, 50 Entry{ 51 Path: "RHEL8/openshift-service-mesh-1.1.oval.xml.bz2", 52 Checksum: unhex("6367a4bc26671e36bd0cd2bbad72c7f5a4b1f2a49948809684e586bc9233131d"), 53 Size: 3340, 54 }, 55 } 56 t.Parallel() 57 f, err := os.Open("testdata/PULP_MANIFEST") 58 if err != nil { 59 t.Fatal(err) 60 } 61 defer f.Close() 62 63 var got Manifest 64 if err := got.Load(f); err != nil { 65 t.Error(err) 66 } 67 if !cmp.Equal(got, want) { 68 t.Error(cmp.Diff(got, want)) 69 } 70 }