Skip to content

Commit

Permalink
fix: fix test case testVendorDeps
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <[email protected]>
  • Loading branch information
zong-zhe committed Nov 20, 2024
1 parent 697a41e commit 5dc9e57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
1 change: 0 additions & 1 deletion pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func TestWithGlobalLock(t *testing.T) {
test.RunTestWithGlobalLock(t, "TestDownloadGitWithPackage", testDownloadGitWithPackage)
test.RunTestWithGlobalLock(t, "TestModandLockFilesWithGitPackageDownload", testModandLockFilesWithGitPackageDownload)
test.RunTestWithGlobalLock(t, "TestDependencyGraph", testDependencyGraph)
test.RunTestWithGlobalLock(t, "TestVendorWithGlobalLock", testVendorWithGlobalLock)
test.RunTestWithGlobalLock(t, "TestPull", testPull)
test.RunTestWithGlobalLock(t, "TestPullWithInsecureSkipTLSverify", testPullWithInsecureSkipTLSverify)
test.RunTestWithGlobalLock(t, "TestPullWithModSpec", testPullWithModSpec)
Expand Down
22 changes: 8 additions & 14 deletions pkg/client/vendor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ import (
"kcl-lang.io/kpm/pkg/features"
pkg "kcl-lang.io/kpm/pkg/package"
"kcl-lang.io/kpm/pkg/settings"
"kcl-lang.io/kpm/pkg/test"
"kcl-lang.io/kpm/pkg/utils"
)

func testVendorDeps(t *testing.T) {
func testVendorDeps(t *testing.T, kpmcli *KpmClient) {
testDir := getTestDir("resolve_deps")
kpm_home := filepath.Join(testDir, "kpm_home")
os.RemoveAll(filepath.Join(testDir, "my_kcl"))
kcl1Sum, _ := utils.HashDir(filepath.Join(kpm_home, "kcl1"))
kcl2Sum, _ := utils.HashDir(filepath.Join(kpm_home, "kcl2"))
kcl1Sum, _ := utils.HashDir(filepath.Join(kpm_home, "kcl1_0.0.1"))
kcl2Sum, _ := utils.HashDir(filepath.Join(kpm_home, "kcl2_0.0.1"))

depKcl1 := pkg.Dependency{
Name: "kcl1",
Expand Down Expand Up @@ -75,10 +74,8 @@ func testVendorDeps(t *testing.T) {

mykclVendorPath := filepath.Join(filepath.Join(testDir, "my_kcl"), "vendor")
assert.Equal(t, utils.DirExists(mykclVendorPath), false)
kpmcli, err := NewKpmClient()
kpmcli.homePath = kpm_home
assert.Equal(t, err, nil)
err = kpmcli.VendorDeps(&kclPkg)
err := kpmcli.VendorDeps(&kclPkg)
assert.Equal(t, err, nil)
assert.Equal(t, utils.DirExists(mykclVendorPath), true)
assert.Equal(t, utils.DirExists(filepath.Join(mykclVendorPath, "kcl1_0.0.1")), true)
Expand All @@ -91,7 +88,7 @@ func testVendorDeps(t *testing.T) {
os.RemoveAll(filepath.Join(testDir, "my_kcl"))
}

func testVendorWithMVS(t *testing.T) {
func testVendorWithMVS(t *testing.T, kpmcli *KpmClient) {
features.Enable(features.SupportMVS)
defer features.Disable(features.SupportMVS)
testDir := getTestDir("test_vendor_mvs")
Expand All @@ -101,9 +98,6 @@ func testVendorWithMVS(t *testing.T) {
pkg.WithSettings(settings.GetSettings()),
)
assert.Equal(t, err, nil)

kpmcli, err := NewKpmClient()
assert.Equal(t, err, nil)
err = kpmcli.VendorDeps(kPkg)
assert.Equal(t, err, nil)

Expand All @@ -112,7 +106,7 @@ func testVendorWithMVS(t *testing.T) {
assert.Equal(t, utils.DirExists(filepath.Join(pkgPath, "vendor", "helloworld_0.1.1")), false)
}

func testVendorWithGlobalLock(t *testing.T) {
test.RunTestWithGlobalLock(t, "TestVendorDeps", testVendorDeps)
test.RunTestWithGlobalLock(t, "TestVendorWithMVS", testVendorWithMVS)
func TestVendorWithGlobalLock(t *testing.T) {
RunTestWithGlobalLockAndKpmCli(t, "TestVendorDeps", testVendorDeps)
RunTestWithGlobalLockAndKpmCli(t, "TestVendorWithMVS", testVendorWithMVS)
}

0 comments on commit 5dc9e57

Please sign in to comment.