Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
asafambar committed Sep 13, 2023
1 parent 87d5bff commit a999bd7
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions build/utils/npm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,13 @@ func TestDependencyWithNoIntegrity(t *testing.T) {
// This test case check that CalculateNpmDependenciesList ignore node_modules and update package-lock.json when needed,
// this according to the params 'IgnoreNodeModules' and 'OverWritePackageLock'.
func TestDependencyPackageLockOnly(t *testing.T) {
path, err := filepath.Abs(filepath.Join("..", "testdata/npm/project6"))
assert.NoError(t, err)
path, cleanup := testdatautils.CreateTestProject(t, filepath.Join("..", "testdata/npm/project6"))
defer cleanup()
data, err := os.ReadFile(filepath.Join(path, "package-lock_test.json"))
require.NoError(t, err)
info, err := os.Stat(filepath.Join(path, "package-lock_test.json"))
require.NoError(t, err)
os.WriteFile(filepath.Join(path, "package-lock.json"), data, info.Mode().Perm())

Check failure on line 214 in build/utils/npm_test.go

View workflow job for this annotation

GitHub Actions / Static-Check

Error return value of `os.WriteFile` is not checked (errcheck)
defer func() {
assert.NoError(t, os.Remove(filepath.Join(path, "package-lock.json")))
assert.NoError(t, os.Remove(filepath.Join(path, "node_modules", ".package-lock.json")))
}()
// sleep so the package.json modified time will be bigger than the package-lock.json, this make sure it will recalculate lock file.
time.Sleep(time.Millisecond * 5)
require.NoError(t, os.Chtimes(filepath.Join(path, "package.json"), time.Now(), time.Now()))
Expand Down

0 comments on commit a999bd7

Please sign in to comment.