From 87b7f0b85322bcfccbb274a6d909ea1e5ead4c25 Mon Sep 17 00:00:00 2001 From: zongz Date: Wed, 20 Nov 2024 14:54:19 +0800 Subject: [PATCH] fix: fix test case TestRunWithOciDownloader Signed-off-by: zongz --- .../run_with_default_dep/kcl.mod.lock.expect | 1 + pkg/client/test_data/test_run_git_package/kcl.mod | 2 +- .../test_run_with_modspec_version/kcl.mod.expect | 2 +- .../kcl.mod.lock.expect | 1 + pkg/visitor/visitor.go | 12 ++++++++++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/client/test_data/run_with_default_dep/kcl.mod.lock.expect b/pkg/client/test_data/run_with_default_dep/kcl.mod.lock.expect index c1bebf8c..7eaf9cba 100644 --- a/pkg/client/test_data/run_with_default_dep/kcl.mod.lock.expect +++ b/pkg/client/test_data/run_with_default_dep/kcl.mod.lock.expect @@ -3,6 +3,7 @@ name = "helloworld" full_name = "helloworld_0.1.2" version = "0.1.2" + sum = "PN0OMEV9M8VGFn1CtA/T3bcgZmMJmOo+RkBrLKIWYeQ=" reg = "ghcr.io" repo = "kcl-lang/helloworld" oci_tag = "0.1.2" diff --git a/pkg/client/test_data/test_run_git_package/kcl.mod b/pkg/client/test_data/test_run_git_package/kcl.mod index 5e0b1cba..cc457753 100644 --- a/pkg/client/test_data/test_run_git_package/kcl.mod +++ b/pkg/client/test_data/test_run_git_package/kcl.mod @@ -4,4 +4,4 @@ edition = "v0.8.0" version = "0.0.1" [dependencies] -k8s = { git = "https://github.com/kcl-lang/modules.git", commit = "ee03122b5f45b09eb48694422fc99a0772f6bba8", package = "k8s" } +k8s = { git = "https://github.com/kcl-lang/modules.git", commit = "ee03122b5f45b09eb48694422fc99a0772f6bba8", package = "k8s", version = "1.31" } diff --git a/pkg/client/test_data/test_run_with_modspec_version/kcl.mod.expect b/pkg/client/test_data/test_run_with_modspec_version/kcl.mod.expect index 46d3ecdf..002d6627 100644 --- a/pkg/client/test_data/test_run_with_modspec_version/kcl.mod.expect +++ b/pkg/client/test_data/test_run_with_modspec_version/kcl.mod.expect @@ -4,4 +4,4 @@ edition = "v0.10.0" version = "0.0.1" [dependencies] -helloworld = { version = "0.1.2" } \ No newline at end of file +helloworld = "0.1.2" \ No newline at end of file diff --git a/pkg/client/test_data/test_run_with_modspec_version/kcl.mod.lock.expect b/pkg/client/test_data/test_run_with_modspec_version/kcl.mod.lock.expect index c1bebf8c..7eaf9cba 100644 --- a/pkg/client/test_data/test_run_with_modspec_version/kcl.mod.lock.expect +++ b/pkg/client/test_data/test_run_with_modspec_version/kcl.mod.lock.expect @@ -3,6 +3,7 @@ name = "helloworld" full_name = "helloworld_0.1.2" version = "0.1.2" + sum = "PN0OMEV9M8VGFn1CtA/T3bcgZmMJmOo+RkBrLKIWYeQ=" reg = "ghcr.io" repo = "kcl-lang/helloworld" oci_tag = "0.1.2" diff --git a/pkg/visitor/visitor.go b/pkg/visitor/visitor.go index 7b005f97..447fedf3 100644 --- a/pkg/visitor/visitor.go +++ b/pkg/visitor/visitor.go @@ -205,10 +205,22 @@ func (rv *RemoteVisitor) Visit(s *downloader.Source, v visitFunc) error { // update the local module path with the latest version. if len(rv.VisitedSpace) != 0 { modFullPath = s.LocalPath(filepath.Join(rv.VisitedSpace, s.Type(), "src")) + if !utils.DirExists(modFullPath) { + err = os.MkdirAll(modFullPath, 0755) + if err != nil { + return err + } + } } // update the cache path with the latest version. if rv.EnableCache { cacheFullPath = s.CachePath(filepath.Join(rv.CachePath, s.Type(), "cache")) + if !utils.DirExists(cacheFullPath) { + err = os.MkdirAll(cacheFullPath, 0755) + if err != nil { + return err + } + } } }