Skip to content

Commit

Permalink
fix: fix test case
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <zongzhe1024@163.com>
  • Loading branch information
zong-zhe committed Dec 12, 2024
1 parent ad3a612 commit 752bc4e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/api/kpm_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func testRunWithNoSumCheck(t *testing.T) {
opts.SetNoSumCheck(false)
_, err = RunPkgInPath(opts)
assert.Equal(t, err, nil)
assert.Equal(t, utils.DirExists(filepath.Join(pkgPath, "kcl.mod.lock")), true)
assert.Equal(t, utils.DirExists(filepath.Join(pkgPath, "kcl.mod.lock")), false)
defer func() {
_ = os.Remove(filepath.Join(pkgPath, "kcl.mod.lock"))
}()
Expand Down
10 changes: 9 additions & 1 deletion pkg/client/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,15 @@ func (c *KpmClient) Update(options ...UpdateOption) (*pkg.KclPkg, error) {
}

if opts.updateModFile {
err = kMod.UpdateModAndLockFile()
err = kMod.UpdateModFile()
if err != nil {
return nil, err
}
}

// Generate file kcl.mod.lock.
if !kMod.NoSumCheck {
err := kMod.LockDepsVersion()
if err != nil {
return nil, err
}
Expand Down
15 changes: 12 additions & 3 deletions pkg/package/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,8 @@ func (kclPkg *KclPkg) LocalVendorPath() string {
return filepath.Join(kclPkg.HomePath, "vendor")
}

// updateModAndLockFile will update kcl.mod and kcl.mod.lock
func (kclPkg *KclPkg) UpdateModAndLockFile() error {

// UpdateModFile will update the kcl.mod file.
func (kclPkg *KclPkg) UpdateModFile() error {
// Load kcl.mod SnapShot.
depSnapShot := kclPkg.depUI

Expand All @@ -412,6 +411,16 @@ func (kclPkg *KclPkg) UpdateModAndLockFile() error {
return err
}

return nil
}

// updateModAndLockFile will update kcl.mod and kcl.mod.lock
func (kclPkg *KclPkg) UpdateModAndLockFile() error {
err := kclPkg.UpdateModFile()
if err != nil {
return err
}

// Generate file kcl.mod.lock.
if !kclPkg.NoSumCheck {
err := kclPkg.LockDepsVersion()
Expand Down

0 comments on commit 752bc4e

Please sign in to comment.