@@ -12,7 +12,8 @@ func TestCreateParameterMapFromFile(t *testing.T) {
12
12
t .Parallel ()
13
13
t .Run ("CreateParameterMapFromFile" ,func (t * testing.T ) {
14
14
t .Parallel ()
15
- parameterFile ,_ := os .CreateTemp (t .TempDir (),"testParameterFile*.yaml" )
15
+ tempDir := t .TempDir ()
16
+ parameterFile ,_ := os .CreateTemp (tempDir ,"testParameterFile*.yaml" )
16
17
_ ,_ = parameterFile .WriteString ("region:\" bananas\" \n disk:\" 20\" \n " )
17
18
18
19
parameterMapFromFile ,err := createParameterMapFromFile (parameterFile .Name ())
@@ -25,7 +26,7 @@ func TestCreateParameterMapFromFile(t *testing.T) {
25
26
assert .Equal (t ,expectedMap ,parameterMapFromFile )
26
27
assert .Nil (t ,err )
27
28
28
- removeTmpDirUntilSuccess (t )
29
+ removeTmpDirUntilSuccess (t , tempDir )
29
30
})
30
31
t .Run ("WithEmptyFilename" ,func (t * testing.T ) {
31
32
t .Parallel ()
@@ -52,23 +53,24 @@ func TestCreateParameterMapFromFile(t *testing.T) {
52
53
})
53
54
t .Run ("WithInvalidYAML" ,func (t * testing.T ) {
54
55
t .Parallel ()
55
- parameterFile ,_ := os .CreateTemp (t .TempDir (),"testParameterFile*.yaml" )
56
+ tempDir := t .TempDir ()
57
+ parameterFile ,_ := os .CreateTemp (tempDir ,"testParameterFile*.yaml" )
56
58
_ ,_ = parameterFile .WriteString ("region =\" bananas\" \n disk =\" 20\" \n " )
57
59
58
60
parameterMapFromFile ,err := createParameterMapFromFile (parameterFile .Name ())
59
61
60
62
assert .Nil (t ,parameterMapFromFile )
61
63
assert .EqualError (t ,err ,"yaml: unmarshal errors:\n line 1: cannot unmarshal !!str `region ...` into map[string]string" )
62
64
63
- removeTmpDirUntilSuccess (t )
65
+ removeTmpDirUntilSuccess (t , tempDir )
64
66
})
65
67
}
66
68
67
- func removeTmpDirUntilSuccess (t * testing.T ) {
69
+ func removeTmpDirUntilSuccess (t * testing.T , tempDir string ) {
68
70
t .Cleanup (func () {
69
- err := os .RemoveAll (t . TempDir () )
71
+ err := os .RemoveAll (tempDir )
70
72
for err != nil {
71
- err = os .RemoveAll (t . TempDir () )
73
+ err = os .RemoveAll (tempDir )
72
74
}
73
75
})
74
76
}