-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from zong-zhe/fix-dep-path
fix: fix missing version when add dependencies from local path
- Loading branch information
Showing
29 changed files
with
201 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ func TestDownloadOci(t *testing.T) { | |
} | ||
kpmcli, err := NewKpmClient() | ||
assert.Equal(t, err, nil) | ||
dep, err := kpmcli.Download(&depFromOci, testPath) | ||
dep, err := kpmcli.Download(&depFromOci, "", testPath) | ||
assert.Equal(t, err, nil) | ||
assert.Equal(t, dep.Name, "k8s") | ||
assert.Equal(t, dep.FullName, "k8s_1.27") | ||
|
@@ -131,7 +131,7 @@ func TestDownloadLatestOci(t *testing.T) { | |
} | ||
kpmcli, err := NewKpmClient() | ||
assert.Equal(t, err, nil) | ||
dep, err := kpmcli.Download(&depFromOci, testPath) | ||
dep, err := kpmcli.Download(&depFromOci, "", testPath) | ||
assert.Equal(t, err, nil) | ||
assert.Equal(t, dep.Name, "helloworld") | ||
assert.Equal(t, dep.FullName, "helloworld_0.1.1") | ||
|
@@ -227,7 +227,7 @@ func TestCyclicDependency(t *testing.T) { | |
|
||
_, _, err = kpmcli.InitGraphAndDownloadDeps(kclPkg) | ||
assert.Equal(t, err, reporter.NewErrorEvent( | ||
reporter.CircularDependencyExist, nil, "adding bbb as a dependency results in a cycle", | ||
reporter.CircularDependencyExist, nil, "adding [email protected] as a dependency results in a cycle", | ||
)) | ||
|
||
err = os.Chdir(currentDir) | ||
|
@@ -1315,3 +1315,53 @@ func TestLoadPkgFormOci(t *testing.T) { | |
assert.Equal(t, kclpkg.GetPkgName(), tc.Name) | ||
} | ||
} | ||
|
||
func TestAddWithLocalPath(t *testing.T) { | ||
|
||
testpath := getTestDir("add_with_local_path") | ||
|
||
initpath := filepath.Join(testpath, "init") | ||
tmppath := filepath.Join(testpath, "tmp") | ||
expectpath := filepath.Join(testpath, "expect") | ||
|
||
defer func() { | ||
err := os.RemoveAll(tmppath) | ||
assert.Equal(t, err, nil) | ||
}() | ||
|
||
err := copy.Copy(initpath, tmppath) | ||
assert.Equal(t, err, nil) | ||
|
||
kpmcli, err := NewKpmClient() | ||
assert.Equal(t, err, nil) | ||
kpmcli.SetLogWriter(nil) | ||
|
||
tmpPkgPath := filepath.Join(tmppath, "pkg") | ||
opts := opt.AddOptions{ | ||
LocalPath: tmpPkgPath, | ||
RegistryOpts: opt.RegistryOptions{ | ||
Oci: &opt.OciOptions{ | ||
Reg: "ghcr.io", | ||
Repo: "kcl-lang", | ||
PkgName: "helloworld", | ||
Tag: "0.1.1", | ||
}, | ||
}, | ||
} | ||
|
||
kclPkg, err := kpmcli.LoadPkgFromPath(tmpPkgPath) | ||
assert.Equal(t, err, nil) | ||
|
||
_, err = kpmcli.AddDepWithOpts(kclPkg, &opts) | ||
assert.Equal(t, err, nil) | ||
|
||
gotpkg, err := kpmcli.LoadPkgFromPath(tmpPkgPath) | ||
assert.Equal(t, err, nil) | ||
expectpath = filepath.Join(expectpath, "pkg") | ||
expectpkg, err := kpmcli.LoadPkgFromPath(expectpath) | ||
assert.Equal(t, err, nil) | ||
|
||
assert.Equal(t, len(gotpkg.Dependencies.Deps), len(expectpkg.Dependencies.Deps)) | ||
assert.Equal(t, gotpkg.Dependencies.Deps["dep_pkg"].FullName, expectpkg.Dependencies.Deps["dep_pkg"].FullName) | ||
assert.Equal(t, gotpkg.Dependencies.Deps["dep_pkg"].Version, expectpkg.Dependencies.Deps["dep_pkg"].Version) | ||
} |
5 changes: 5 additions & 0 deletions
5
pkg/client/test_data/add_with_local_path/expect/dep_pkg/kcl.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
name = "dep_pkg" | ||
edition = "v0.8.0" | ||
version = "0.0.1" | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The_first_kcl_program = 'Hello World!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "pkg" | ||
edition = "v0.8.0" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
dep_pkg = { path = "../dep_pkg" } | ||
helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.1" } |
15 changes: 15 additions & 0 deletions
15
pkg/client/test_data/add_with_local_path/expect/pkg/kcl.mod.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[dependencies] | ||
[dependencies.dep_pkg] | ||
name = "dep_pkg" | ||
full_name = "dep_pkg_0.0.1" | ||
version = "0.0.1" | ||
sum = "C3TjaZJVdt4G8TtbiCxTUO/zAlf7fWJTAvs/CDMnlxY=" | ||
path = "../dep_pkg" | ||
[dependencies.helloworld] | ||
name = "helloworld" | ||
full_name = "helloworld_0.1.1" | ||
version = "0.1.1" | ||
sum = "7OO4YK2QuRWPq9C7KTzcWcti5yUnueCjptT3OXiPVeQ=" | ||
reg = "ghcr.io" | ||
repo = "kcl-lang/helloworld" | ||
oci_tag = "0.1.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The_first_kcl_program = 'Hello World!' |
5 changes: 5 additions & 0 deletions
5
pkg/client/test_data/add_with_local_path/init/dep_pkg/kcl.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
name = "dep_pkg" | ||
edition = "v0.8.0" | ||
version = "0.0.1" | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The_first_kcl_program = 'Hello World!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "pkg" | ||
edition = "v0.8.0" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
dep_pkg = { path = "../dep_pkg" } |
7 changes: 7 additions & 0 deletions
7
pkg/client/test_data/add_with_local_path/init/pkg/kcl.mod.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[dependencies] | ||
[dependencies.dep_pkg] | ||
name = "dep_pkg" | ||
full_name = "dep_pkg_0.0.1" | ||
version = "0.0.1" | ||
sum = "C3TjaZJVdt4G8TtbiCxTUO/zAlf7fWJTAvs/CDMnlxY=" | ||
path = "../dep_pkg" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The_first_kcl_program = 'Hello World!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path/test_suite.env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
KPM_HOME="" | ||
KCLVM_VENDOR_HOME="" |
1 change: 1 addition & 0 deletions
1
test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path/test_suite.input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
kpm run <workspace>/pkg1 |
Empty file.
1 change: 1 addition & 0 deletions
1
test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path/test_suite.stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The_first_kcl_program: Hello World! |
8 changes: 8 additions & 0 deletions
8
test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg1/kcl.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "pkg1" | ||
edition = "v0.8.0" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
pkg2 = { path = "../pkg2" } | ||
pkg3 = { path = "../pkg3" } |
13 changes: 13 additions & 0 deletions
13
test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg1/kcl.mod.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[dependencies] | ||
[dependencies.pkg2] | ||
name = "pkg2" | ||
full_name = "pkg2_0.0.1" | ||
version = "0.0.1" | ||
sum = "JbfIAXPJb3L6xX7hi/A5mrXzjpB8eFoKfEmJMdHsewY=" | ||
path = "../pkg2" | ||
[dependencies.pkg3] | ||
name = "pkg3" | ||
full_name = "pkg3_0.0.1" | ||
version = "0.0.1" | ||
sum = "T29gAv6K/tLithhP5jVHyurV5zRFui+i1ulyMt/ncnM=" | ||
path = "../pkg3" |
3 changes: 3 additions & 0 deletions
3
test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg1/main.k
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import pkg2 | ||
|
||
The_first_kcl_program = pkg2.The_first_kcl_program |
7 changes: 7 additions & 0 deletions
7
test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg2/kcl.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "pkg2" | ||
edition = "v0.8.0" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
pkg3 = { path = "../pkg3" } |
Oops, something went wrong.