From 8977f9a524c276e81fa199b81cd56b7282b9f3c0 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 10 Jul 2015 20:39:30 -0700 Subject: [PATCH] cached api test should also have a custom config path, would conflict with your .minio local path --- pkg/server/api_donut_cache_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/server/api_donut_cache_test.go b/pkg/server/api_donut_cache_test.go index 137a9c4db..53643ddb8 100644 --- a/pkg/server/api_donut_cache_test.go +++ b/pkg/server/api_donut_cache_test.go @@ -19,6 +19,8 @@ package server import ( "bytes" "io/ioutil" + "os" + "path/filepath" "strings" "testing" @@ -33,19 +35,33 @@ import ( func TestAPIDonutCache(t *testing.T) { TestingT(t) } -type MyAPIDonutCacheSuite struct{} +type MyAPIDonutCacheSuite struct { + root string +} var _ = Suite(&MyAPIDonutCacheSuite{}) var testAPIDonutCacheServer *httptest.Server func (s *MyAPIDonutCacheSuite) SetUpSuite(c *C) { + root, err := ioutil.TempDir(os.TempDir(), "api-") + c.Assert(err, IsNil) + s.root = root + + conf := new(donut.Config) + conf.Version = "0.0.1" + conf.MaxSize = 100000 + donut.CustomConfigPath = filepath.Join(root, "donut.json") + err = donut.SaveConfig(conf) + c.Assert(err, IsNil) + httpHandler, minioAPI := getAPIHandler(api.Config{RateLimit: 16}) go startTM(minioAPI) testAPIDonutCacheServer = httptest.NewServer(httpHandler) } func (s *MyAPIDonutCacheSuite) TearDownSuite(c *C) { + os.RemoveAll(s.root) testAPIDonutCacheServer.Close() }