Skip to content

Commit

Permalink
Fix golang test files (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
sverdlov93 authored Oct 1, 2023
1 parent dbddec5 commit 14d5188
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions packagehandlers/packagehandlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/jfrog/frogbot/utils"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-cli-core/v2/xray/formats"
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
"github.com/stretchr/testify/assert"
"os"
"path/filepath"
Expand Down Expand Up @@ -586,12 +587,25 @@ func createTempDirAndChdir(t *testing.T, testdataDir string, tech string) func()
currDir, err := os.Getwd()
assert.NoError(t, err)
assert.NoError(t, os.Chdir(tmpProjectPath))
if tech == "go" {
err = removeTxtSuffix("go.mod.txt")
assert.NoError(t, err)
err = removeTxtSuffix("go.sum.txt")
assert.NoError(t, err)
err = removeTxtSuffix("main.go.txt")
assert.NoError(t, err)
}
return func() {
cleanup()
assert.NoError(t, os.Chdir(currDir))
}
}

func removeTxtSuffix(txtFileName string) error {
// go.sum.txt >> go.sum
return fileutils.MoveFile(txtFileName, strings.TrimSuffix(txtFileName, ".txt"))
}

func assertFixVersionInPackageDescriptor(t *testing.T, test dependencyFixTest, packageDescriptor string) {
file, err := os.ReadFile(packageDescriptor)
assert.NoError(t, err)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions utils/scandetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ func (sc *ScanDetails) runInstallCommand() ([]byte, error) {
//#nosec G204 -- False positive - the subprocess only runs after the user's approval.
return exec.Command(sc.InstallCommandName, sc.InstallCommandArgs...).CombinedOutput()
}

if _, exists := MapTechToResolvingFunc[sc.InstallCommandName]; !exists {
resolveDepsFunc := MapTechToResolvingFunc[sc.InstallCommandName]
if resolveDepsFunc == nil {
return nil, fmt.Errorf(sc.InstallCommandName, "isn't recognized as an install command")
}
log.Info("Resolving dependencies from", sc.ServerDetails.Url, "from repo", sc.DepsRepo)
return MapTechToResolvingFunc[sc.InstallCommandName](sc)
return resolveDepsFunc(sc)
}

func (sc *ScanDetails) SetXscGitInfoContext(scannedBranch, gitProject string, client vcsclient.VcsClient) *ScanDetails {
Expand Down

0 comments on commit 14d5188

Please sign in to comment.