From 582ce3df36d2a12c56d33c497d4b575e22f6346a Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 3 Feb 2015 00:25:33 -0800 Subject: [PATCH] Make sure config testing is done in tempdir --- pkg/utils/config/config_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/utils/config/config_test.go b/pkg/utils/config/config_test.go index 48194d543..cf91b6e2b 100644 --- a/pkg/utils/config/config_test.go +++ b/pkg/utils/config/config_test.go @@ -1,9 +1,13 @@ package config import ( + "os" + "path" + "sync" "testing" "github.com/minio-io/minio/pkg/utils/crypto/keys" + "github.com/minio-io/minio/pkg/utils/helpers" . "gopkg.in/check.v1" ) @@ -15,7 +19,16 @@ func Test(t *testing.T) { TestingT(t) } func (s *MySuite) TestConfig(c *C) { conf := Config{} - conf.SetupConfig() + conf.configPath, _ = helpers.MakeTempTestDir() + defer os.RemoveAll(conf.configPath) + conf.configFile = path.Join(conf.configPath, "config.json") + if _, err := os.Stat(conf.configFile); os.IsNotExist(err) { + _, err = os.Create(conf.configFile) + if err != nil { + c.Fatal(err) + } + } + conf.configLock = new(sync.RWMutex) accesskey, _ := keys.GetRandomAlphaNumeric(keys.MINIO_ACCESS_ID) secretkey, _ := keys.GetRandomBase64(keys.MINIO_SECRET_ID)