Skip to content

Commit

Permalink
fix: fix windows path
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <[email protected]>
  • Loading branch information
zong-zhe committed Nov 22, 2024
1 parent 49f7da8 commit 5fb1425
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions pkg/client/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,41 +99,46 @@ func TestKclIssue1760(t *testing.T) {
func TestKpmIssue550(t *testing.T) {
testPath := "github.com/kcl-lang/kpm/issues/550"
testCases := []struct {
name string
setup func()
expected string
name string
setup func()
expected string
winExpected string
}{
{
name: "Default",
setup: func() {
features.Disable(features.SupportNewStorage)
features.Disable(features.SupportMVS)
},
expected: filepath.Join("flask-demo-kcl-manifests_test-branch-without-modfile", "aa", "cc"),
expected: filepath.Join("flask-demo-kcl-manifests_test-branch-without-modfile", "aa", "cc"),
winExpected: filepath.Join("flask-demo-kcl-manifests_test-branch-without-modfile", "aa", "cc"),
},
{
name: "SupportNewStorage",
setup: func() {
features.Enable(features.SupportNewStorage)
features.Disable(features.SupportMVS)
},
expected: filepath.Join("git", "src", "200297ed26e4aeb7", "flask-demo-kcl-manifests", "test-branch-without-modfile", "aa", "cc"),
expected: filepath.Join("git", "src", "200297ed26e4aeb7", "flask-demo-kcl-manifests", "test-branch-without-modfile", "aa", "cc"),
winExpected: filepath.Join("git", "src", "3523a44a55384201", "flask-demo-kcl-manifests", "test-branch-without-modfile", "aa", "cc"),
},
{
name: "SupportMVS",
setup: func() {
features.Disable(features.SupportNewStorage)
features.Enable(features.SupportMVS)
},
expected: filepath.Join("flask-demo-kcl-manifests_test-branch-without-modfile", "aa", "cc"),
expected: filepath.Join("flask-demo-kcl-manifests_test-branch-without-modfile", "aa", "cc"),
winExpected: filepath.Join("flask-demo-kcl-manifests_test-branch-without-modfile", "aa", "cc"),
},
{
name: "SupportNewStorageAndMVS",
setup: func() {
features.Enable(features.SupportNewStorage)
features.Enable(features.SupportMVS)
},
expected: filepath.Join("git", "src", "200297ed26e4aeb7", "flask-demo-kcl-manifests", "test-branch-without-modfile", "aa", "cc"),
expected: filepath.Join("git", "src", "200297ed26e4aeb7", "flask-demo-kcl-manifests", "test-branch-without-modfile", "aa", "cc"),
winExpected: filepath.Join("git", "src", "3523a44a55384201", "flask-demo-kcl-manifests", "test-branch-without-modfile", "aa", "cc"),
},
}

Expand Down Expand Up @@ -172,7 +177,7 @@ func TestKpmIssue550(t *testing.T) {

expectedPath := filepath.Join(tmpKpmHome, tc.expected)
if runtime.GOOS == "windows" {
expectedPath = filepath.Join(tmpKpmHome, tc.expected)
expectedPath = filepath.Join(tmpKpmHome, tc.winExpected)
expectedPath = strings.ReplaceAll(expectedPath, "\\", "\\\\")
}

Expand All @@ -192,7 +197,11 @@ func TestKpmIssue550(t *testing.T) {
"cloning 'https://github.com/kcl-lang/flask-demo-kcl-manifests.git' with branch 'test-branch-without-modfile'",
)
assert.Equal(t, len(resMap), 1)
assert.Equal(t, resMap["cc"], filepath.Join(tmpKpmHome, tc.expected))
if runtime.GOOS == "windows" {
assert.Equal(t, resMap["cc"], filepath.Join(tmpKpmHome, tc.winExpected))
} else {
assert.Equal(t, resMap["cc"], filepath.Join(tmpKpmHome, tc.expected))
}
}

RunTestWithGlobalLockAndKpmCli(t, tc.name, testFunc)
Expand Down

0 comments on commit 5fb1425

Please sign in to comment.