Skip to content

Commit

Permalink
Fix testdata project path in Yarn tests (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
eranturgeman authored Mar 14, 2024
1 parent 2299b78 commit 5bc1339
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions commands/audit/sca/yarn/yarn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
utils2 "github.com/jfrog/build-info-go/utils"
"github.com/jfrog/jfrog-cli-core/v2/utils/tests"
"github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
xrayUtils "github.com/jfrog/jfrog-client-go/xray/services/utils"
"github.com/stretchr/testify/assert"
"path/filepath"
Expand Down Expand Up @@ -55,11 +56,16 @@ func TestParseYarnDependenciesList(t *testing.T) {
func TestIsInstallRequired(t *testing.T) {
tempDirPath, createTempDirCallback := tests.CreateTempDirWithCallbackAndAssert(t)
defer createTempDirCallback()
yarnProjectPath := filepath.Join("..", "..", "..", "testdata", "yarn-project")
yarnProjectPath := filepath.Join("..", "..", "..", "..", "tests", "testdata", "projects", "package-managers", "yarn", "yarn-project")
assert.NoError(t, utils2.CopyDir(yarnProjectPath, tempDirPath, true, nil))
installRequired, err := isInstallRequired(tempDirPath, []string{})
assert.NoError(t, err)
assert.True(t, installRequired)

isTempDirEmpty, err := fileutils.IsDirEmpty(tempDirPath)
assert.NoError(t, err)
assert.False(t, isTempDirEmpty)

executablePath, err := biutils.GetYarnExecutable()
assert.NoError(t, err)

Expand All @@ -85,9 +91,13 @@ func TestRunYarnInstallAccordingToVersion(t *testing.T) {
func executeRunYarnInstallAccordingToVersionAndVerifyInstallation(t *testing.T, params []string) {
tempDirPath, createTempDirCallback := tests.CreateTempDirWithCallbackAndAssert(t)
defer createTempDirCallback()
yarnProjectPath := filepath.Join("..", "..", "..", "testdata", "yarn-project")
yarnProjectPath := filepath.Join("..", "..", "..", "..", "tests", "testdata", "projects", "package-managers", "yarn", "yarn-project")
assert.NoError(t, utils2.CopyDir(yarnProjectPath, tempDirPath, true, nil))

isTempDirEmpty, err := fileutils.IsDirEmpty(tempDirPath)
assert.NoError(t, err)
assert.False(t, isTempDirEmpty)

executablePath, err := biutils.GetYarnExecutable()
assert.NoError(t, err)

Expand Down

0 comments on commit 5bc1339

Please sign in to comment.