@@ -2,6 +2,7 @@ package cli
2
2
3
3
import (
4
4
"os"
5
+ "runtime"
5
6
"testing"
6
7
7
8
"github.com/stretchr/testify/assert"
@@ -23,6 +24,8 @@ func TestCreateParameterMapFromFile(t *testing.T) {
23
24
24
25
assert .Equal (t ,expectedMap ,parameterMapFromFile )
25
26
assert .Nil (t ,err )
27
+
28
+ removeTmpDirUntilSuccess (t )
26
29
})
27
30
t .Run ("WithEmptyFilename" ,func (t * testing.T ) {
28
31
t .Parallel ()
@@ -38,7 +41,14 @@ func TestCreateParameterMapFromFile(t *testing.T) {
38
41
parameterMapFromFile ,err := createParameterMapFromFile ("invalidFile.yaml" )
39
42
40
43
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
+ if runtime .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
+ }
42
52
})
43
53
t .Run ("WithInvalidYAML" ,func (t * testing.T ) {
44
54
t .Parallel ()
@@ -49,5 +59,16 @@ func TestCreateParameterMapFromFile(t *testing.T) {
49
59
50
60
assert .Nil (t ,parameterMapFromFile )
51
61
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
+ func removeTmpDirUntilSuccess (t * testing.T ) {
68
+ t .Cleanup (func () {
69
+ err := os .RemoveAll (t .TempDir ())
70
+ for err != nil {
71
+ err = os .RemoveAll (t .TempDir ())
72
+ }
52
73
})
53
74
}