github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/pkg/cataloger/java/parse_pom_properties_test.go (about) 1 package java 2 3 import ( 4 "os" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 9 "github.com/anchore/syft/syft/pkg" 10 ) 11 12 func TestParseJavaPomProperties(t *testing.T) { 13 tests := []struct { 14 expected pkg.PomProperties 15 }{ 16 { 17 expected: pkg.PomProperties{ 18 Path: "test-fixtures/pom/small.pom.properties", 19 GroupID: "org.anchore", 20 ArtifactID: "example-java-app-maven", 21 Version: "0.1.0", 22 }, 23 }, 24 { 25 expected: pkg.PomProperties{ 26 Path: "test-fixtures/pom/extra.pom.properties", 27 GroupID: "org.anchore", 28 ArtifactID: "example-java-app-maven", 29 Version: "0.1.0", 30 Name: "something-here", 31 Extra: map[string]string{ 32 "another": "thing", 33 "sweet": "work", 34 }, 35 }, 36 }, 37 { 38 expected: pkg.PomProperties{ 39 Path: "test-fixtures/pom/colon-delimited.pom.properties", 40 GroupID: "org.anchore", 41 ArtifactID: "example-java-app-maven", 42 Version: "0.1.0", 43 }, 44 }, 45 { 46 expected: pkg.PomProperties{ 47 Path: "test-fixtures/pom/equals-delimited-with-colons.pom.properties", 48 GroupID: "org.anchore", 49 ArtifactID: "example-java:app-maven", 50 Version: "0.1.0:something", 51 }, 52 }, 53 { 54 expected: pkg.PomProperties{ 55 Path: "test-fixtures/pom/colon-delimited-with-equals.pom.properties", 56 GroupID: "org.anchore", 57 ArtifactID: "example-java=app-maven", 58 Version: "0.1.0=something", 59 }, 60 }, 61 } 62 63 for _, test := range tests { 64 t.Run(test.expected.Path, func(t *testing.T) { 65 fixture, err := os.Open(test.expected.Path) 66 assert.NoError(t, err) 67 68 actual, err := parsePomProperties(fixture.Name(), fixture) 69 assert.NoError(t, err) 70 71 assert.Equal(t, &test.expected, actual) 72 }) 73 } 74 }