Skip to content

Commit

Permalink
Add flag to all restore commands
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Nov 21, 2024
1 parent 27fe40f commit 070229f
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions nuget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"encoding/xml"
"github.com/jfrog/jfrog-client-go/utils/log"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -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...)
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 070229f

Please sign in to comment.