Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artifactory resolution tests: Python, Java, Go #2354

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
revert last change
eranturgeman committed Dec 17, 2023
commit 26f94d978fa9917794d9b4b0b86a9e000b907790
2 changes: 1 addition & 1 deletion go_test.go
Original file line number Diff line number Diff line change
@@ -309,7 +309,7 @@ func cleanGoTest(t *testing.T) {
deleteSpec := spec.NewBuilder().Pattern(tests.GoRepo).BuildSpec()
_, _, err := tests.DeleteFiles(deleteSpec, serverDetails)
assert.NoError(t, err)
assert.NoError(t, cleanTestsHomeEnv())
cleanTestsHomeEnv()
}

func createTempGoPath(t *testing.T) (tempGoPath string, cleanUp func()) {
5 changes: 2 additions & 3 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -149,10 +149,9 @@ func prepareHomeDir(t *testing.T) (string, string) {
return oldHomeDir, newHomeDir
}

func cleanTestsHomeEnv() error {
err := os.Unsetenv(coreutils.HomeDir)
func cleanTestsHomeEnv() {
os.Unsetenv(coreutils.HomeDir)
tests.CleanFileSystem()
return err
}

func validateBuildInfo(buildInfo buildinfo.BuildInfo, t *testing.T, expectedDependencies int, expectedArtifacts int, moduleName string, moduleType buildinfo.ModuleType) {
4 changes: 2 additions & 2 deletions nuget_test.go
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ func testNativeNugetDotnetResolve(t *testing.T, uniqueTests []testDescriptor, bu
testNugetCmd(t, projectPath, buildName, strconv.Itoa(buildNumber), test.expectedModules, test.args, test.expectedDependencies)
})
}
assert.NoError(t, cleanTestsHomeEnv())
cleanTestsHomeEnv()
}

func createNugetProject(t *testing.T, projectName string) string {
@@ -108,7 +108,7 @@ func TestNuGetWithGlobalConfig(t *testing.T) {
assert.NoError(t, err)
testNugetCmd(t, projectPath, tests.NuGetBuildName, "1", []string{"packagesconfig"}, []string{"nuget", "restore"}, []int{6})

assert.NoError(t, cleanTestsHomeEnv())
cleanTestsHomeEnv()
}

func testNugetCmd(t *testing.T, projectPath, buildName, buildNumber string, expectedModule, args []string, expectedDependencies []int) {
16 changes: 4 additions & 12 deletions xray_test.go
Original file line number Diff line number Diff line change
@@ -443,9 +443,7 @@ func TestXrayAuditMultiProjects(t *testing.T) {
filepath.Join(tempDirPath, "python", "pip"), filepath.Join(tempDirPath, "jas-test"))
// Configure a new server named "default"
createJfrogHomeConfig(t, true)
defer func() {
assert.NoError(t, cleanTestsHomeEnv())
}()
defer cleanTestsHomeEnv()
output := xrayCli.WithoutCredentials().RunCliCmdWithOutput(t, "audit", "--format="+string(utils.SimpleJson), workingDirsFlag)
verifySimpleJsonScanResults(t, output, 35, 0)
verifySimpleJsonJasResults(t, output, 1, 9, 7, 3)
@@ -641,9 +639,7 @@ func TestXrayCurl(t *testing.T) {
initXrayTest(t, "")
// Configure a new server named "default".
createJfrogHomeConfig(t, true)
defer func() {
assert.NoError(t, cleanTestsHomeEnv())
}()
defer cleanTestsHomeEnv()
// Check curl command with the default configured server.
err := xrayCli.WithoutCredentials().Exec("xr", "curl", "-XGET", "/api/v1/system/version")
assert.NoError(t, err)
@@ -806,9 +802,7 @@ func testXrayAuditJas(t *testing.T, format string, project string) string {
assert.NoError(t, biutils.CopyDir(projectDir, tempDirPath, true, nil))
// Configure a new server named "default"
createJfrogHomeConfig(t, true)
defer func() {
assert.NoError(t, cleanTestsHomeEnv())
}()
defer cleanTestsHomeEnv()
baseWd, err := os.Getwd()
assert.NoError(t, err)
chdirCallback := clientTestUtils.ChangeDirWithCallback(t, baseWd, tempDirPath)
@@ -1039,9 +1033,7 @@ func TestDependencyResolutionFromArtifactory(t *testing.T) {
},
}
createJfrogHomeConfig(t, true)
defer func() {
assert.NoError(t, cleanTestsHomeEnv())
}()
defer cleanTestsHomeEnv()
eranturgeman marked this conversation as resolved.
Show resolved Hide resolved

for _, testCase := range testCases {
t.Run(testCase.projectType.String(), func(t *testing.T) {