Skip to content

Commit 2037685

Browse files
committed
fix: fix test case
Signed-off-by: zongz <zongzhe1024@163.com>
1 parent 722ba4c commit 2037685

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

pkg/client/client.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -863,11 +863,18 @@ func (c *KpmClient) Download(dep *pkg.Dependency, homePath, localPath string) (*
863863
return nil, err
864864
}
865865
dep.FromKclPkg(dpkg)
866-
dep.LocalFullPath = localPath + dep.Version
867-
err = os.Rename(localPath, dep.LocalFullPath)
868-
if err != nil {
869-
return nil, err
866+
867+
if dep.LocalFullPath == "" {
868+
dep.LocalFullPath = localPath
869+
}
870+
871+
if localPath != dep.LocalFullPath {
872+
err = os.Rename(localPath, dep.LocalFullPath)
873+
if err != nil {
874+
return nil, err
875+
}
870876
}
877+
871878
// Creating symbolic links in a global cache is not an optimal solution.
872879
// This allows kclvm to locate the package by default.
873880
// This feature is unstable and will be removed soon.

pkg/client/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func TestDownloadLatestOci(t *testing.T) {
144144
assert.Equal(t, dep.Source.Oci.Reg, "ghcr.io")
145145
assert.Equal(t, dep.Source.Oci.Repo, "kcl-lang/helloworld")
146146
assert.Equal(t, dep.Source.Oci.Tag, "0.1.1")
147-
assert.Equal(t, dep.LocalFullPath, testPath+"0.1.1")
147+
assert.Equal(t, dep.LocalFullPath, testPath)
148148
assert.Equal(t, err, nil)
149149

150150
// Check whether the tar downloaded by `kpm add` has been deleted.

0 commit comments

Comments
 (0)