diff --git a/internal/mavenutil/maven_test.go b/internal/mavenutil/maven_test.go index b7fbcbef..c30ad9c4 100644 --- a/internal/mavenutil/maven_test.go +++ b/internal/mavenutil/maven_test.go @@ -1,6 +1,7 @@ package mavenutil_test import ( + "path/filepath" "testing" "github.com/google/osv-scalibr/internal/mavenutil" @@ -8,9 +9,9 @@ import ( ) func TestParentPOMPath(t *testing.T) { - input := extracttest.GenerateScanInputMock(t, extracttest.ScanInputMockConfig{ - Path: "fixtures/my-app/pom.xml", - }) + input := extracttest.GenerateScanInputMock(t, extracttest.ScanInputMockConfig{}) + defer extracttest.CloseTestScanInput(t, input) + tests := []struct { currentPath, relativePath string want string @@ -24,37 +25,37 @@ func TestParentPOMPath(t *testing.T) { // |- pom.xml { // Parent path is specified correctly. - currentPath: "fixtures/my-app/pom.xml", + currentPath: filepath.Join("fixtures", "my-app", "pom.xml"), relativePath: "../parent/pom.xml", - want: "fixtures/parent/pom.xml", + want: filepath.Join("fixtures", "parent", "pom.xml"), }, { // Wrong file name is specified in relative path. - currentPath: "fixtures/my-app/pom.xml", + currentPath: filepath.Join("fixtures", "my-app", "pom.xml"), relativePath: "../parent/abc.xml", want: "", }, { // Wrong directory is specified in relative path. - currentPath: "fixtures/my-app/pom.xml", + currentPath: filepath.Join("fixtures", "my-app", "pom.xml"), relativePath: "../not-found/pom.xml", want: "", }, { // Only directory is specified. - currentPath: "fixtures/my-app/pom.xml", + currentPath: filepath.Join("fixtures", "my-app", "pom.xml"), relativePath: "../parent", - want: "fixtures/parent/pom.xml", + want: filepath.Join("fixtures", "parent", "pom.xml"), }, { // Parent relative path is default to '../pom.xml'. - currentPath: "fixtures/my-app/pom.xml", + currentPath: filepath.Join("fixtures", "my-app", "pom.xml"), relativePath: "", - want: "fixtures/pom.xml", + want: filepath.Join("fixtures", "pom.xml"), }, { // No pom.xml is found even in the default path. - currentPath: "fixtures/pom.xml", + currentPath: filepath.Join("fixtures", "pom.xml"), relativePath: "", want: "", },