github.com/quay/claircore@v1.5.28/aws/updater_test.go (about) 1 package aws 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/google/go-cmp/cmp" 8 9 "github.com/quay/claircore/aws/internal/alas" 10 ) 11 12 func TestVersionString(t *testing.T) { 13 testcases := []struct { 14 pkg alas.Package 15 expected string 16 }{ 17 { 18 pkg: alas.Package{ 19 Epoch: "", 20 Version: "3.3.10", 21 Release: "26.amzn2", 22 }, 23 expected: "3.3.10-26.amzn2", 24 }, 25 { 26 pkg: alas.Package{ 27 Epoch: "0", 28 Version: "3.3.10", 29 Release: "26.amzn2", 30 }, 31 expected: "3.3.10-26.amzn2", 32 }, 33 { 34 pkg: alas.Package{ 35 Epoch: "10", 36 Version: "3.1.0", 37 Release: "8.amzn2.0.8", 38 }, 39 expected: "10:3.1.0-8.amzn2.0.8", 40 }, 41 } 42 43 var b strings.Builder 44 for _, testcase := range testcases { 45 v := versionString(&b, testcase.pkg) 46 if !cmp.Equal(v, testcase.expected) { 47 t.Errorf(cmp.Diff(v, testcase.expected)) 48 } 49 } 50 }