github.com/quay/claircore@v1.5.28/photon/distributionscanner_test.go (about) 1 package photon 2 3 import ( 4 "bytes" 5 "testing" 6 7 "github.com/google/go-cmp/cmp" 8 ) 9 10 var photon1OSRelease []byte = []byte(`NAME="VMware Photon" 11 VERSION="1.0" 12 ID=photon 13 VERSION_ID="1.0" 14 PRETTY_NAME="VMware Photon/Linux" 15 ANSI_COLOR="1;34" 16 HOME_URL="https://vmware.github.io/photon/" 17 BUG_REPORT_URL="https://github.com/vmware/photon/issues"`) 18 19 var photon2OSRelease []byte = []byte(`NAME="VMware Photon OS" 20 VERSION="2.0" 21 ID=photon 22 VERSION_ID="2.0" 23 PRETTY_NAME="VMware Photon OS/Linux" 24 ANSI_COLOR="1;34" 25 HOME_URL="https://vmware.github.io/photon/" 26 BUG_REPORT_URL="https://github.com/vmware/photon/issues"`) 27 28 var photon3OSRelease []byte = []byte(`NAME="VMware Photon OS" 29 VERSION="3.0" 30 ID=photon 31 VERSION_ID="3.0" 32 PRETTY_NAME="VMware Photon OS/Linux" 33 ANSI_COLOR="1;34" 34 HOME_URL="https://vmware.github.io/photon/" 35 BUG_REPORT_URL="https://github.com/vmware/photon/issues"`) 36 37 func TestDistributionScanner(t *testing.T) { 38 table := []struct { 39 name string 40 release Release 41 osRelease []byte 42 }{ 43 { 44 name: "photon 1.0", 45 release: Photon1, 46 osRelease: photon1OSRelease, 47 }, 48 { 49 name: "photon 2.0", 50 release: Photon2, 51 osRelease: photon2OSRelease, 52 }, 53 { 54 name: "photon 3.0", 55 release: Photon3, 56 osRelease: photon3OSRelease, 57 }, 58 } 59 for _, tt := range table { 60 t.Run(tt.name, func(t *testing.T) { 61 scanner := DistributionScanner{} 62 dist := scanner.parse(bytes.NewBuffer(tt.osRelease)) 63 if !cmp.Equal(dist, releaseToDist(tt.release)) { 64 t.Fatalf("%v", cmp.Diff(dist, releaseToDist(tt.release))) 65 } 66 }) 67 } 68 }