Skip to content

Commit

Permalink
test: fix mavenBuild getPurl tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Germanov committed Oct 29, 2024
1 parent 8faf232 commit f1df2c1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions cmd/mavenBuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
var cpe mavenBuildCommonPipelineEnvironment

func TestMavenBuild(t *testing.T) {

t.Run("mavenBuild should install the artifact", func(t *testing.T) {
mockedUtils := newMavenMockUtils()

Expand Down Expand Up @@ -123,7 +122,6 @@ func TestMavenBuild(t *testing.T) {
assert.Equal(t, mockedUtils.Calls[0].Exec, "mvn")
assert.Empty(t, cpe.custom.mavenBuildArtifacts)
})

}

func createTempFile(t *testing.T, dir string, filename string, content string) string {
Expand All @@ -136,7 +134,6 @@ func createTempFile(t *testing.T, dir string, filename string, content string) s
}

func TestGetPurlForThePomAndDeleteIndividualBom(t *testing.T) {

t.Run("valid BOM file, aggregated BOM", func(t *testing.T) {
tempDir, err := piperutils.Files{}.TempDir("", "test")
if err != nil {
Expand All @@ -160,7 +157,7 @@ func TestGetPurlForThePomAndDeleteIndividualBom(t *testing.T) {
}
bomFilePath := createTempFile(t, bomDir, mvnSimpleBomFilename+".xml", bomContent)

purl := getPurlForThePom(pomFilePath)
purl := piperutils.GetPurl(pomFilePath, mvnSimpleBomFilename+".xml")
assert.Equal(t, "pkg:maven/com.example/[email protected]", purl)
_, err = os.Stat(bomFilePath)
assert.False(t, os.IsNotExist(err)) // File should not be deleted
Expand All @@ -170,7 +167,7 @@ func TestGetPurlForThePomAndDeleteIndividualBom(t *testing.T) {
tempDir := t.TempDir()
pomFilePath := createTempFile(t, tempDir, "pom.xml", "") // Create a temp pom file

purl := getPurlForThePom(pomFilePath)
purl := piperutils.GetPurl(pomFilePath, mvnSimpleBomFilename+".xml")
assert.Equal(t, "", purl)
})
}

0 comments on commit f1df2c1

Please sign in to comment.