Skip to content

Commit 86b1028

Browse files
committed
Fix unit tests for Windows
1 parent 1a12be1 commit 86b1028

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

cli/parameter_internal_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ func TestCreateParameterMapFromFile(t *testing.T) {
1212
t.Parallel()
1313
t.Run("CreateParameterMapFromFile", func(t *testing.T) {
1414
t.Parallel()
15-
parameterFile, _ := os.CreateTemp(t.TempDir(), "testParameterFile*.yaml")
15+
tempDir := t.TempDir()
16+
parameterFile, _ := os.CreateTemp(tempDir, "testParameterFile*.yaml")
1617
_, _ = parameterFile.WriteString("region: \"bananas\"\ndisk: \"20\"\n")
1718

1819
parameterMapFromFile, err := createParameterMapFromFile(parameterFile.Name())
@@ -25,7 +26,7 @@ func TestCreateParameterMapFromFile(t *testing.T) {
2526
assert.Equal(t, expectedMap, parameterMapFromFile)
2627
assert.Nil(t, err)
2728

28-
removeTmpDirUntilSuccess(t)
29+
removeTmpDirUntilSuccess(t, tempDir)
2930
})
3031
t.Run("WithEmptyFilename", func(t *testing.T) {
3132
t.Parallel()
@@ -52,23 +53,24 @@ func TestCreateParameterMapFromFile(t *testing.T) {
5253
})
5354
t.Run("WithInvalidYAML", func(t *testing.T) {
5455
t.Parallel()
55-
parameterFile, _ := os.CreateTemp(t.TempDir(), "testParameterFile*.yaml")
56+
tempDir := t.TempDir()
57+
parameterFile, _ := os.CreateTemp(tempDir, "testParameterFile*.yaml")
5658
_, _ = parameterFile.WriteString("region = \"bananas\"\ndisk = \"20\"\n")
5759

5860
parameterMapFromFile, err := createParameterMapFromFile(parameterFile.Name())
5961

6062
assert.Nil(t, parameterMapFromFile)
6163
assert.EqualError(t, err, "yaml: unmarshal errors:\n line 1: cannot unmarshal !!str `region ...` into map[string]string")
6264

63-
removeTmpDirUntilSuccess(t)
65+
removeTmpDirUntilSuccess(t, tempDir)
6466
})
6567
}
6668

67-
func removeTmpDirUntilSuccess(t *testing.T) {
69+
func removeTmpDirUntilSuccess(t *testing.T, tempDir string) {
6870
t.Cleanup(func() {
69-
err := os.RemoveAll(t.TempDir())
71+
err := os.RemoveAll(tempDir)
7072
for err != nil {
71-
err = os.RemoveAll(t.TempDir())
73+
err = os.RemoveAll(tempDir)
7274
}
7375
})
7476
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy