Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a12be1

Browse files
committed
Fix unit tests for windows
1 parent692b975 commit1a12be1

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

‎cli/parameter_internal_test.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cli
22

33
import (
44
"os"
5+
"runtime"
56
"testing"
67

78
"github.com/stretchr/testify/assert"
@@ -23,6 +24,8 @@ func TestCreateParameterMapFromFile(t *testing.T) {
2324

2425
assert.Equal(t,expectedMap,parameterMapFromFile)
2526
assert.Nil(t,err)
27+
28+
removeTmpDirUntilSuccess(t)
2629
})
2730
t.Run("WithEmptyFilename",func(t*testing.T) {
2831
t.Parallel()
@@ -38,7 +41,14 @@ func TestCreateParameterMapFromFile(t *testing.T) {
3841
parameterMapFromFile,err:=createParameterMapFromFile("invalidFile.yaml")
3942

4043
assert.Nil(t,parameterMapFromFile)
41-
assert.EqualError(t,err,"open invalidFile.yaml: no such file or directory")
44+
45+
// On Unix based systems, it is: `open invalidFile.yaml: no such file or directory`
46+
// On Windows, it is `open invalidFile.yaml: The system cannot find the file specified.`
47+
ifruntime.GOOS=="windows" {
48+
assert.EqualError(t,err,"open invalidFile.yaml: The system cannot find the file specified.")
49+
}else {
50+
assert.EqualError(t,err,"open invalidFile.yaml: no such file or directory")
51+
}
4252
})
4353
t.Run("WithInvalidYAML",func(t*testing.T) {
4454
t.Parallel()
@@ -49,5 +59,16 @@ func TestCreateParameterMapFromFile(t *testing.T) {
4959

5060
assert.Nil(t,parameterMapFromFile)
5161
assert.EqualError(t,err,"yaml: unmarshal errors:\n line 1: cannot unmarshal !!str `region ...` into map[string]string")
62+
63+
removeTmpDirUntilSuccess(t)
64+
})
65+
}
66+
67+
funcremoveTmpDirUntilSuccess(t*testing.T) {
68+
t.Cleanup(func() {
69+
err:=os.RemoveAll(t.TempDir())
70+
forerr!=nil {
71+
err=os.RemoveAll(t.TempDir())
72+
}
5273
})
5374
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp