Skip to content

Commit e5513d1

Browse files
committed
change temp dir strategy in config_test
1 parent 8d2f4bd commit e5513d1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

config/config_test.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ func getDefaultConfiguration() *Config {
2222
}
2323
}
2424

25+
var configurationPath string = getConfigPath()
26+
2527
func getConfigPath() string {
26-
tempDir := os.TempDir()
28+
tempDir, _ := ioutil.TempDir("", "temp")
29+
2730
return path.Join(tempDir, "config.yaml")
2831
}
2932

3033
func createFakeConfigFile() error {
31-
configPath := getConfigPath()
34+
configPath := configurationPath
3235

3336
var buffer bytes.Buffer
3437
configuration := getDefaultConfiguration()
@@ -49,7 +52,7 @@ func createFakeConfigFile() error {
4952
func TestLoadConfiguration(t *testing.T) {
5053
_ = createFakeConfigFile()
5154
defer deleteFakeConfigFile()
52-
config, err := LoadConfiguration(getConfigPath())
55+
config, err := LoadConfiguration(configurationPath)
5356
if err != nil {
5457
t.Error(err)
5558
}
@@ -58,7 +61,7 @@ func TestLoadConfiguration(t *testing.T) {
5861
}
5962

6063
func deleteFakeConfigFile() {
61-
configPath := getConfigPath()
64+
configPath := configurationPath
6265
_ = os.Remove(configPath)
6366
}
6467

0 commit comments

Comments
 (0)