From 361d245ef18daefb5e7fc6a23b744d119f5dc9bf Mon Sep 17 00:00:00 2001 From: zongz Date: Fri, 20 Dec 2024 11:39:09 +0800 Subject: [PATCH 1/2] test: add more test cases for the new storage Signed-off-by: zongz --- pkg/client/client_test.go | 463 ++++++++++++++++++ .../test_data/test_new_storage/mod/kcl.mod | 7 + .../test_new_storage/mod/kcl.mod.lock | 9 + .../test_data/test_new_storage/mod/main.k | 1 + .../test_data/test_new_storage/mod_0/kcl.mod | 7 + .../test_new_storage/mod_0/kcl.mod.lock | 9 + .../test_data/test_new_storage/mod_0/main.k | 1 + .../test_data/test_new_storage/mod_1/kcl.mod | 7 + .../test_new_storage/mod_1/kcl.mod.lock | 7 + .../test_data/test_new_storage/mod_1/main.k | 1 + .../test_data/test_new_storage/mod_2/kcl.mod | 7 + .../test_new_storage/mod_2/kcl.mod.lock | 7 + .../test_data/test_new_storage/mod_2/main.k | 1 + .../test_data/test_new_storage/mod_3/kcl.mod | 7 + .../test_new_storage/mod_3/kcl.mod.lock | 9 + .../test_data/test_new_storage/mod_3/main.k | 1 + .../test_data/test_new_storage/mod_4/kcl.mod | 7 + .../test_new_storage/mod_4/kcl.mod.lock | 9 + .../test_data/test_new_storage/mod_4/main.k | 1 + .../test_data/test_new_storage/mod_5/kcl.mod | 7 + .../test_new_storage/mod_5/kcl.mod.lock | 7 + .../test_data/test_new_storage/mod_5/main.k | 1 + .../test_data/test_new_storage/mod_6/kcl.mod | 7 + .../test_new_storage/mod_6/kcl.mod.lock | 7 + .../test_data/test_new_storage/mod_6/main.k | 1 + 25 files changed, 591 insertions(+) create mode 100644 pkg/client/test_data/test_new_storage/mod/kcl.mod create mode 100644 pkg/client/test_data/test_new_storage/mod/kcl.mod.lock create mode 100644 pkg/client/test_data/test_new_storage/mod/main.k create mode 100644 pkg/client/test_data/test_new_storage/mod_0/kcl.mod create mode 100644 pkg/client/test_data/test_new_storage/mod_0/kcl.mod.lock create mode 100644 pkg/client/test_data/test_new_storage/mod_0/main.k create mode 100644 pkg/client/test_data/test_new_storage/mod_1/kcl.mod create mode 100644 pkg/client/test_data/test_new_storage/mod_1/kcl.mod.lock create mode 100644 pkg/client/test_data/test_new_storage/mod_1/main.k create mode 100644 pkg/client/test_data/test_new_storage/mod_2/kcl.mod create mode 100644 pkg/client/test_data/test_new_storage/mod_2/kcl.mod.lock create mode 100644 pkg/client/test_data/test_new_storage/mod_2/main.k create mode 100644 pkg/client/test_data/test_new_storage/mod_3/kcl.mod create mode 100644 pkg/client/test_data/test_new_storage/mod_3/kcl.mod.lock create mode 100644 pkg/client/test_data/test_new_storage/mod_3/main.k create mode 100644 pkg/client/test_data/test_new_storage/mod_4/kcl.mod create mode 100644 pkg/client/test_data/test_new_storage/mod_4/kcl.mod.lock create mode 100644 pkg/client/test_data/test_new_storage/mod_4/main.k create mode 100644 pkg/client/test_data/test_new_storage/mod_5/kcl.mod create mode 100644 pkg/client/test_data/test_new_storage/mod_5/kcl.mod.lock create mode 100644 pkg/client/test_data/test_new_storage/mod_5/main.k create mode 100644 pkg/client/test_data/test_new_storage/mod_6/kcl.mod create mode 100644 pkg/client/test_data/test_new_storage/mod_6/kcl.mod.lock create mode 100644 pkg/client/test_data/test_new_storage/mod_6/main.k diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 804d559b..5be2b30e 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -28,6 +28,7 @@ import ( "kcl-lang.io/kpm/pkg/downloader" "kcl-lang.io/kpm/pkg/env" "kcl-lang.io/kpm/pkg/features" + "kcl-lang.io/kpm/pkg/git" "kcl-lang.io/kpm/pkg/opt" pkg "kcl-lang.io/kpm/pkg/package" "kcl-lang.io/kpm/pkg/reporter" @@ -2319,3 +2320,465 @@ func TestValidateDependency(t *testing.T) { err = kpmcli.ValidateDependency(&dep2) assert.Error(t, err) } + +func TestAddOciDepLocalStorage(t *testing.T) { + testFunc := func(t *testing.T, kpmcli *KpmClient) { + features.Disable(features.SupportNewStorage) + testKpmHome := filepath.Join(getTestDir("test_new_storage"), "kpm_home") + modPath := filepath.Join(getTestDir("test_new_storage"), "mod") + defer func() { + _ = os.RemoveAll(testKpmHome) + }() + + var buf bytes.Buffer + + kpmcli.SetHomePath(testKpmHome) + kpmcli.SetLogWriter(&buf) + + mod, err := pkg.LoadKclPkgWithOpts( + pkg.WithPath(modPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + + err = kpmcli.Add( + WithAddKclPkg(mod), + WithAddSource(&downloader.Source{ + Oci: &downloader.Oci{ + Reg: "ghcr.io", + Repo: "kcl-lang/helloworld", + Tag: "0.1.2", + }, + ModSpec: &downloader.ModSpec{ + Name: "helloworld", + Version: "0.1.2", + }, + }), + ) + + if err != nil { + t.Fatal(err) + } + + assert.Equal(t, buf.String(), + "downloading 'kcl-lang/helloworld:0.1.2' from 'ghcr.io/kcl-lang/helloworld:0.1.2'\n"+ + "adding dependency 'helloworld'\n"+ + "add dependency 'helloworld:0.1.2' successfully\n", + ) + + depPath := filepath.Join(testKpmHome, "helloworld_0.1.2") + _, err = pkg.LoadKclPkgWithOpts( + pkg.WithPath(depPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + } + RunTestWithGlobalLockAndKpmCli(t, []TestSuite{{Name: "TestAddOciDepLocalStorage", TestFunc: testFunc}}) +} + +func TestAddOciNewLocalStorage(t *testing.T) { + testFunc := func(t *testing.T, kpmcli *KpmClient) { + features.Enable(features.SupportNewStorage) + testKpmHome := filepath.Join(getTestDir("test_new_storage"), "kpm_home") + modPath := filepath.Join(getTestDir("test_new_storage"), "mod_0") + defer func() { + _ = os.RemoveAll(testKpmHome) + features.Disable(features.SupportNewStorage) + }() + var buf bytes.Buffer + + kpmcli.SetHomePath(testKpmHome) + kpmcli.SetLogWriter(&buf) + + mod, err := pkg.LoadKclPkgWithOpts( + pkg.WithPath(modPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + + depSource := &downloader.Source{ + Oci: &downloader.Oci{ + Reg: "ghcr.io", + Repo: "kcl-lang/helloworld", + Tag: "0.1.2", + }, + ModSpec: &downloader.ModSpec{ + Name: "helloworld", + Version: "0.1.2", + }, + } + + err = kpmcli.Add( + WithAddKclPkg(mod), + WithAddSource(depSource), + ) + + if err != nil { + t.Fatal(err) + } + + cachePath := filepath.Join(depSource.CachePath(filepath.Join(testKpmHome, "oci", "cache")), "helloworld_0.1.2.tar") + assert.Equal(t, true, utils.DirExists(cachePath)) + + assert.Equal(t, buf.String(), + "downloading 'kcl-lang/helloworld:0.1.2' from 'ghcr.io/kcl-lang/helloworld:0.1.2'\n"+ + "adding dependency 'helloworld'\n"+ + "add dependency 'helloworld:0.1.2' successfully\n", + ) + + depPath := filepath.Join(depSource.LocalPath(filepath.Join(testKpmHome, "oci", "src"))) + _, err = pkg.LoadKclPkgWithOpts( + pkg.WithPath(depPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + } + RunTestWithGlobalLockAndKpmCli(t, []TestSuite{{Name: "TestAddOciNewLocalStorage", TestFunc: testFunc}}) +} + +func TestAddGitDepLocalStorage(t *testing.T) { + testFunc := func(t *testing.T, kpmcli *KpmClient) { + features.Disable(features.SupportNewStorage) + testKpmHome := filepath.Join(getTestDir("test_new_storage"), "kpm_home") + modPath := filepath.Join(getTestDir("test_new_storage"), "mod_1") + defer func() { + _ = os.RemoveAll(testKpmHome) + }() + + var buf bytes.Buffer + + kpmcli.SetHomePath(testKpmHome) + kpmcli.SetLogWriter(&buf) + + mod, err := pkg.LoadKclPkgWithOpts( + pkg.WithPath(modPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + + err = kpmcli.Add( + WithAddKclPkg(mod), + WithAddSource(&downloader.Source{ + Git: &downloader.Git{ + Url: "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", + Branch: "main", + }, + }), + ) + + if err != nil { + t.Fatal(err) + } + + assert.Equal(t, buf.String(), + "cloning 'https://github.com/kcl-lang/flask-demo-kcl-manifests.git' with branch 'main'\n"+ + "adding dependency 'flask_manifests'\n", + ) + + depPath := filepath.Join(testKpmHome, "flask-demo-kcl-manifests_main") + _, err = pkg.LoadKclPkgWithOpts( + pkg.WithPath(depPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + } + RunTestWithGlobalLockAndKpmCli(t, []TestSuite{{Name: "TestAddGitDepLocalStorage", TestFunc: testFunc}}) +} + +func TestAddGitNewLocalStorage(t *testing.T) { + testFunc := func(t *testing.T, kpmcli *KpmClient) { + features.Enable(features.SupportNewStorage) + testKpmHome := filepath.Join(getTestDir("test_new_storage"), "kpm_home") + modPath := filepath.Join(getTestDir("test_new_storage"), "mod_2") + defer func() { + _ = os.RemoveAll(testKpmHome) + features.Disable(features.SupportNewStorage) + }() + + var buf bytes.Buffer + + kpmcli.SetHomePath(testKpmHome) + kpmcli.SetLogWriter(&buf) + + mod, err := pkg.LoadKclPkgWithOpts( + pkg.WithPath(modPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + + gitSource := &downloader.Source{ + Git: &downloader.Git{ + Url: "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", + Branch: "main", + }, + } + + err = kpmcli.Add( + WithAddKclPkg(mod), + WithAddSource(gitSource), + ) + + if err != nil { + t.Fatal(err) + } + + assert.Equal(t, buf.String(), "cloning 'https://github.com/kcl-lang/flask-demo-kcl-manifests.git' with branch 'main'\n"+ + "adding dependency 'flask_manifests'\n"+ + "add dependency 'flask_manifests:0.0.1' successfully\n", + ) + + depPath := gitSource.LocalPath(filepath.Join(testKpmHome, "git", "src")) + _, err = pkg.LoadKclPkgWithOpts( + pkg.WithPath(depPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + + cachePath := gitSource.CachePath(filepath.Join(testKpmHome, "git", "cache")) + + assert.Equal(t, true, utils.DirExists(cachePath)) + assert.Equal(t, git.IsGitBareRepo(cachePath), true) + } + RunTestWithGlobalLockAndKpmCli(t, []TestSuite{{Name: "TestAddGitNewLocalStorage", TestFunc: testFunc}}) +} + +func TestUpdateOciDepLocalStorage(t *testing.T) { + testFunc := func(t *testing.T, kpmcli *KpmClient) { + features.Disable(features.SupportNewStorage) + testKpmHome := filepath.Join(getTestDir("test_new_storage"), "kpm_home") + modPath := filepath.Join(getTestDir("test_new_storage"), "mod_3") + defer func() { + _ = os.RemoveAll(testKpmHome) + }() + + var buf bytes.Buffer + + kpmcli.SetHomePath(testKpmHome) + kpmcli.SetLogWriter(&buf) + + mod, err := pkg.LoadKclPkgWithOpts( + pkg.WithPath(modPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + + _, err = kpmcli.Update( + WithUpdatedKclPkg(mod), + ) + + if err != nil { + t.Fatal(err) + } + + assert.Equal(t, buf.String(), + "downloading 'kcl-lang/helloworld:0.1.2' from 'ghcr.io/kcl-lang/helloworld:0.1.2'\n") + + depPath := filepath.Join(testKpmHome, "helloworld_0.1.2") + _, err = pkg.LoadKclPkgWithOpts( + pkg.WithPath(depPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + } + RunTestWithGlobalLockAndKpmCli(t, []TestSuite{{Name: "TestUpdateOciDepLocalStorage", TestFunc: testFunc}}) +} + +func TestUpdateOciNewLocalStorage(t *testing.T) { + testFunc := func(t *testing.T, kpmcli *KpmClient) { + features.Enable(features.SupportNewStorage) + testKpmHome := filepath.Join(getTestDir("test_new_storage"), "kpm_home") + modPath := filepath.Join(getTestDir("test_new_storage"), "mod_4") + defer func() { + _ = os.RemoveAll(testKpmHome) + features.Disable(features.SupportNewStorage) + }() + var buf bytes.Buffer + + kpmcli.SetHomePath(testKpmHome) + kpmcli.SetLogWriter(&buf) + + mod, err := pkg.LoadKclPkgWithOpts( + pkg.WithPath(modPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + + depSource := &downloader.Source{ + Oci: &downloader.Oci{ + Reg: "ghcr.io", + Repo: "kcl-lang/helloworld", + Tag: "0.1.2", + }, + ModSpec: &downloader.ModSpec{ + Name: "helloworld", + Version: "0.1.2", + }, + } + + _, err = kpmcli.Update( + WithUpdatedKclPkg(mod), + ) + + if err != nil { + t.Fatal(err) + } + + cachePath := filepath.Join(depSource.CachePath(filepath.Join(testKpmHome, "oci", "cache")), "helloworld_0.1.2.tar") + assert.Equal(t, true, utils.DirExists(cachePath)) + + assert.Equal(t, buf.String(), + "downloading 'kcl-lang/helloworld:0.1.2' from 'ghcr.io/kcl-lang/helloworld:0.1.2'\n", + ) + + depPath := filepath.Join(depSource.LocalPath(filepath.Join(testKpmHome, "oci", "src"))) + _, err = pkg.LoadKclPkgWithOpts( + pkg.WithPath(depPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + } + RunTestWithGlobalLockAndKpmCli(t, []TestSuite{{Name: "TestUpdateOciNewLocalStorage", TestFunc: testFunc}}) +} + +func TestUpdateGitDepLocalStorage(t *testing.T) { + testFunc := func(t *testing.T, kpmcli *KpmClient) { + features.Disable(features.SupportNewStorage) + testKpmHome := filepath.Join(getTestDir("test_new_storage"), "kpm_home") + modPath := filepath.Join(getTestDir("test_new_storage"), "mod_5") + defer func() { + _ = os.RemoveAll(testKpmHome) + }() + + var buf bytes.Buffer + + kpmcli.SetHomePath(testKpmHome) + kpmcli.SetLogWriter(&buf) + + mod, err := pkg.LoadKclPkgWithOpts( + pkg.WithPath(modPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + + _, err = kpmcli.Update( + WithUpdatedKclPkg(mod), + ) + + if err != nil { + t.Fatal(err) + } + + assert.Equal(t, buf.String(), + "cloning 'https://github.com/kcl-lang/flask-demo-kcl-manifests.git' with branch 'main'\n", + ) + + depPath := filepath.Join(testKpmHome, "flask-demo-kcl-manifests_main") + _, err = pkg.LoadKclPkgWithOpts( + pkg.WithPath(depPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + } + RunTestWithGlobalLockAndKpmCli(t, []TestSuite{{Name: "TestUpdateGitDepLocalStorage", TestFunc: testFunc}}) +} + +func TestUpdateGitNewLocalStorage(t *testing.T) { + testFunc := func(t *testing.T, kpmcli *KpmClient) { + features.Enable(features.SupportNewStorage) + testKpmHome := filepath.Join(getTestDir("test_new_storage"), "kpm_home") + modPath := filepath.Join(getTestDir("test_new_storage"), "mod_6") + defer func() { + _ = os.RemoveAll(testKpmHome) + features.Disable(features.SupportNewStorage) + }() + + var buf bytes.Buffer + + kpmcli.SetHomePath(testKpmHome) + kpmcli.SetLogWriter(&buf) + + mod, err := pkg.LoadKclPkgWithOpts( + pkg.WithPath(modPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + + gitSource := &downloader.Source{ + Git: &downloader.Git{ + Url: "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", + Branch: "main", + }, + } + + _, err = kpmcli.Update( + WithUpdatedKclPkg(mod), + ) + + if err != nil { + t.Fatal(err) + } + + assert.Equal(t, buf.String(), "cloning 'https://github.com/kcl-lang/flask-demo-kcl-manifests.git' with branch 'main'\n") + + depPath := gitSource.LocalPath(filepath.Join(testKpmHome, "git", "src")) + _, err = pkg.LoadKclPkgWithOpts( + pkg.WithPath(depPath), + pkg.WithSettings(kpmcli.GetSettings()), + ) + + if err != nil { + t.Fatal(err) + } + + cachePath := gitSource.CachePath(filepath.Join(testKpmHome, "git", "cache")) + + assert.Equal(t, true, utils.DirExists(cachePath)) + assert.Equal(t, git.IsGitBareRepo(cachePath), true) + } + RunTestWithGlobalLockAndKpmCli(t, []TestSuite{{Name: "TestUpdateGitNewLocalStorage", TestFunc: testFunc}}) +} diff --git a/pkg/client/test_data/test_new_storage/mod/kcl.mod b/pkg/client/test_data/test_new_storage/mod/kcl.mod new file mode 100644 index 00000000..c284f79b --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "mod" +edition = "v0.11.0-alpha.1" +version = "0.0.1" + +[dependencies] +helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.2", version = "0.1.2" } diff --git a/pkg/client/test_data/test_new_storage/mod/kcl.mod.lock b/pkg/client/test_data/test_new_storage/mod/kcl.mod.lock new file mode 100644 index 00000000..7eaf9cba --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod/kcl.mod.lock @@ -0,0 +1,9 @@ +[dependencies] + [dependencies.helloworld] + 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_new_storage/mod/main.k b/pkg/client/test_data/test_new_storage/mod/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/pkg/client/test_data/test_new_storage/mod_0/kcl.mod b/pkg/client/test_data/test_new_storage/mod_0/kcl.mod new file mode 100644 index 00000000..c284f79b --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_0/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "mod" +edition = "v0.11.0-alpha.1" +version = "0.0.1" + +[dependencies] +helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.2", version = "0.1.2" } diff --git a/pkg/client/test_data/test_new_storage/mod_0/kcl.mod.lock b/pkg/client/test_data/test_new_storage/mod_0/kcl.mod.lock new file mode 100644 index 00000000..7eaf9cba --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_0/kcl.mod.lock @@ -0,0 +1,9 @@ +[dependencies] + [dependencies.helloworld] + 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_new_storage/mod_0/main.k b/pkg/client/test_data/test_new_storage/mod_0/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_0/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/pkg/client/test_data/test_new_storage/mod_1/kcl.mod b/pkg/client/test_data/test_new_storage/mod_1/kcl.mod new file mode 100644 index 00000000..e2d4c7bb --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_1/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "mod" +edition = "v0.11.0-alpha.1" +version = "0.0.1" + +[dependencies] +flask_manifests = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", branch = "main", version = "0.0.1" } diff --git a/pkg/client/test_data/test_new_storage/mod_1/kcl.mod.lock b/pkg/client/test_data/test_new_storage/mod_1/kcl.mod.lock new file mode 100644 index 00000000..b4affed4 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_1/kcl.mod.lock @@ -0,0 +1,7 @@ +[dependencies] + [dependencies.flask_manifests] + name = "flask_manifests" + full_name = "flask_manifests_0.0.1" + version = "0.0.1" + url = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git" + branch = "main" diff --git a/pkg/client/test_data/test_new_storage/mod_1/main.k b/pkg/client/test_data/test_new_storage/mod_1/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_1/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/pkg/client/test_data/test_new_storage/mod_2/kcl.mod b/pkg/client/test_data/test_new_storage/mod_2/kcl.mod new file mode 100644 index 00000000..e2d4c7bb --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_2/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "mod" +edition = "v0.11.0-alpha.1" +version = "0.0.1" + +[dependencies] +flask_manifests = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", branch = "main", version = "0.0.1" } diff --git a/pkg/client/test_data/test_new_storage/mod_2/kcl.mod.lock b/pkg/client/test_data/test_new_storage/mod_2/kcl.mod.lock new file mode 100644 index 00000000..b4affed4 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_2/kcl.mod.lock @@ -0,0 +1,7 @@ +[dependencies] + [dependencies.flask_manifests] + name = "flask_manifests" + full_name = "flask_manifests_0.0.1" + version = "0.0.1" + url = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git" + branch = "main" diff --git a/pkg/client/test_data/test_new_storage/mod_2/main.k b/pkg/client/test_data/test_new_storage/mod_2/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_2/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/pkg/client/test_data/test_new_storage/mod_3/kcl.mod b/pkg/client/test_data/test_new_storage/mod_3/kcl.mod new file mode 100644 index 00000000..c284f79b --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_3/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "mod" +edition = "v0.11.0-alpha.1" +version = "0.0.1" + +[dependencies] +helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.2", version = "0.1.2" } diff --git a/pkg/client/test_data/test_new_storage/mod_3/kcl.mod.lock b/pkg/client/test_data/test_new_storage/mod_3/kcl.mod.lock new file mode 100644 index 00000000..7eaf9cba --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_3/kcl.mod.lock @@ -0,0 +1,9 @@ +[dependencies] + [dependencies.helloworld] + 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_new_storage/mod_3/main.k b/pkg/client/test_data/test_new_storage/mod_3/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_3/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/pkg/client/test_data/test_new_storage/mod_4/kcl.mod b/pkg/client/test_data/test_new_storage/mod_4/kcl.mod new file mode 100644 index 00000000..c284f79b --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_4/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "mod" +edition = "v0.11.0-alpha.1" +version = "0.0.1" + +[dependencies] +helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.2", version = "0.1.2" } diff --git a/pkg/client/test_data/test_new_storage/mod_4/kcl.mod.lock b/pkg/client/test_data/test_new_storage/mod_4/kcl.mod.lock new file mode 100644 index 00000000..7eaf9cba --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_4/kcl.mod.lock @@ -0,0 +1,9 @@ +[dependencies] + [dependencies.helloworld] + 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_new_storage/mod_4/main.k b/pkg/client/test_data/test_new_storage/mod_4/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_4/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/pkg/client/test_data/test_new_storage/mod_5/kcl.mod b/pkg/client/test_data/test_new_storage/mod_5/kcl.mod new file mode 100644 index 00000000..e2d4c7bb --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_5/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "mod" +edition = "v0.11.0-alpha.1" +version = "0.0.1" + +[dependencies] +flask_manifests = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", branch = "main", version = "0.0.1" } diff --git a/pkg/client/test_data/test_new_storage/mod_5/kcl.mod.lock b/pkg/client/test_data/test_new_storage/mod_5/kcl.mod.lock new file mode 100644 index 00000000..b4affed4 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_5/kcl.mod.lock @@ -0,0 +1,7 @@ +[dependencies] + [dependencies.flask_manifests] + name = "flask_manifests" + full_name = "flask_manifests_0.0.1" + version = "0.0.1" + url = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git" + branch = "main" diff --git a/pkg/client/test_data/test_new_storage/mod_5/main.k b/pkg/client/test_data/test_new_storage/mod_5/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_5/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/pkg/client/test_data/test_new_storage/mod_6/kcl.mod b/pkg/client/test_data/test_new_storage/mod_6/kcl.mod new file mode 100644 index 00000000..e2d4c7bb --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_6/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "mod" +edition = "v0.11.0-alpha.1" +version = "0.0.1" + +[dependencies] +flask_manifests = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", branch = "main", version = "0.0.1" } diff --git a/pkg/client/test_data/test_new_storage/mod_6/kcl.mod.lock b/pkg/client/test_data/test_new_storage/mod_6/kcl.mod.lock new file mode 100644 index 00000000..b4affed4 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_6/kcl.mod.lock @@ -0,0 +1,7 @@ +[dependencies] + [dependencies.flask_manifests] + name = "flask_manifests" + full_name = "flask_manifests_0.0.1" + version = "0.0.1" + url = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git" + branch = "main" diff --git a/pkg/client/test_data/test_new_storage/mod_6/main.k b/pkg/client/test_data/test_new_storage/mod_6/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/pkg/client/test_data/test_new_storage/mod_6/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file From f09ddb95bf1501b5932f1b53f6ea0257f63546b9 Mon Sep 17 00:00:00 2001 From: zongz Date: Fri, 20 Dec 2024 11:44:40 +0800 Subject: [PATCH 2/2] fix: fix missing message in test case Signed-off-by: zongz --- pkg/client/client_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 5be2b30e..1fec285b 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -2487,7 +2487,8 @@ func TestAddGitDepLocalStorage(t *testing.T) { assert.Equal(t, buf.String(), "cloning 'https://github.com/kcl-lang/flask-demo-kcl-manifests.git' with branch 'main'\n"+ - "adding dependency 'flask_manifests'\n", + "adding dependency 'flask_manifests'\n"+ + "add dependency 'flask_manifests:0.0.1' successfully\n", ) depPath := filepath.Join(testKpmHome, "flask-demo-kcl-manifests_main")