From 070229f674fea688cb37bfdf0fb8d353ef07aede Mon Sep 17 00:00:00 2001 From: delarea Date: Thu, 21 Nov 2024 15:38:00 +0200 Subject: [PATCH] Add flag to all restore commands --- nuget_test.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/nuget_test.go b/nuget_test.go index 93242d14c..ac03bb8b2 100644 --- a/nuget_test.go +++ b/nuget_test.go @@ -2,7 +2,6 @@ package main import ( "encoding/xml" - "github.com/jfrog/jfrog-client-go/utils/log" "os" "path/filepath" "strconv" @@ -109,18 +108,18 @@ func TestNuGetWithGlobalConfig(t *testing.T) { err = createConfigFileForTest([]string{jfrogHomeDir}, tests.NugetRemoteRepo, "", t, project.Nuget, true) assert.NoError(t, err) // allow insecure connection for testings to work with localhost server - testNugetCmd(t, projectPath, tests.NuGetBuildName, "1", []string{"packagesconfig"}, []string{"nuget", "restore"}, []int{6}, project.Nuget.String()) + testNugetCmd(t, projectPath, tests.NuGetBuildName, "1", []string{"packagesconfig"}, []string{"nuget", "restore"}, []int{6}) cleanTestsHomeEnv() } -func testNugetCmd(t *testing.T, projectPath, buildName, buildNumber string, expectedModule, args []string, expectedDependencies []int, projectType string) { +func testNugetCmd(t *testing.T, projectPath, buildName, buildNumber string, expectedModule, args []string, expectedDependencies []int) { wd, err := os.Getwd() assert.NoError(t, err, "Failed to get current dir") chdirCallback := clientTestUtils.ChangeDirWithCallback(t, wd, projectPath) defer chdirCallback() - allowInsecureConnectionForTests(projectType, &args) + allowInsecureConnectionForTests(&args) args = append(args, "--build-name="+buildName, "--build-number="+buildNumber) err = runNuGet(t, args...) @@ -158,12 +157,10 @@ func testNugetCmd(t *testing.T, projectPath, buildName, buildNumber string, expe } // Add allow insecure connection for testings to work with localhost server -// dotNet also uses this cmd, and we want to apply this only for Nuget. -func allowInsecureConnectionForTests(projectType string, args *[]string) *[]string { - if projectType == project.Nuget.String() { +func allowInsecureConnectionForTests(args *[]string) *[]string { + if slices.Contains(*args, "restore") { *args = append(*args, "--allow-insecure-connections") } - log.Debug(projectType) return args }