Make sure config testing is done in tempdir

master
Harshavardhana 10 years ago
parent f4cd0aa978
commit 582ce3df36
  1. 15
      pkg/utils/config/config_test.go

@ -1,9 +1,13 @@
package config package config
import ( import (
"os"
"path"
"sync"
"testing" "testing"
"github.com/minio-io/minio/pkg/utils/crypto/keys" "github.com/minio-io/minio/pkg/utils/crypto/keys"
"github.com/minio-io/minio/pkg/utils/helpers"
. "gopkg.in/check.v1" . "gopkg.in/check.v1"
) )
@ -15,7 +19,16 @@ func Test(t *testing.T) { TestingT(t) }
func (s *MySuite) TestConfig(c *C) { func (s *MySuite) TestConfig(c *C) {
conf := Config{} 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) accesskey, _ := keys.GetRandomAlphaNumeric(keys.MINIO_ACCESS_ID)
secretkey, _ := keys.GetRandomBase64(keys.MINIO_SECRET_ID) secretkey, _ := keys.GetRandomBase64(keys.MINIO_SECRET_ID)

Loading…
Cancel
Save