From 20d46a19778f01382b2abcd1a4c8a6030f43bfbf Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 13 Dec 2014 01:14:36 -0800 Subject: [PATCH] Provide new pkgs/utils for generic functions --- pkgs/gateway/gateway_test.go | 6 +++--- pkgs/storage/appendstorage/append_storage_test.go | 11 ++++------- pkgs/storage/encodedstorage/encoded_storage_test.go | 11 ++++------- pkgs/storage/fsstorage/fs_storage_test.go | 7 ++----- pkgs/{miniotest => utils}/helpers.go | 2 +- 5 files changed, 14 insertions(+), 23 deletions(-) rename pkgs/{miniotest => utils}/helpers.go (85%) diff --git a/pkgs/gateway/gateway_test.go b/pkgs/gateway/gateway_test.go index 0ea62cd9d..ed9542cff 100644 --- a/pkgs/gateway/gateway_test.go +++ b/pkgs/gateway/gateway_test.go @@ -8,7 +8,7 @@ import ( "strings" "github.com/gorilla/mux" - "github.com/minio-io/minio/pkgs/miniotest" + "github.com/minio-io/minio/pkgs/utils" . "gopkg.in/check.v1" ) @@ -104,9 +104,9 @@ func (s *GatewaySuite) TestBucketCreation(c *C) { } func (s *GatewaySuite) TestInMemoryBucketOperations(c *C) { - simpleFileStorageRootDir, err1 := miniotest.MakeTempTestDir() + simpleFileStorageRootDir, err1 := utils.MakeTempTestDir() c.Assert(err1, IsNil) - simpleEncodedStorageRootDir, err2 := miniotest.MakeTempTestDir() + simpleEncodedStorageRootDir, err2 := utils.MakeTempTestDir() c.Assert(err2, IsNil) defer os.RemoveAll(simpleFileStorageRootDir) defer os.RemoveAll(simpleEncodedStorageRootDir) diff --git a/pkgs/storage/appendstorage/append_storage_test.go b/pkgs/storage/appendstorage/append_storage_test.go index d526a2e8f..b79ada26e 100644 --- a/pkgs/storage/appendstorage/append_storage_test.go +++ b/pkgs/storage/appendstorage/append_storage_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/minio-io/minio/pkgs/storage" + "github.com/minio-io/minio/pkgs/utils" . "gopkg.in/check.v1" ) @@ -16,12 +17,8 @@ var _ = Suite(&AppendStorageSuite{}) func Test(t *testing.T) { TestingT(t) } -func makeTempTestDir() (string, error) { - return ioutil.TempDir("/tmp", "minio-test-") -} - func (s *AppendStorageSuite) TestAppendStoragePutAtRootPath(c *C) { - rootDir, err := makeTempTestDir() + rootDir, err := utils.MakeTempTestDir() c.Assert(err, IsNil) defer os.RemoveAll(rootDir) @@ -54,7 +51,7 @@ func (s *AppendStorageSuite) TestAppendStoragePutAtRootPath(c *C) { } func (s *AppendStorageSuite) TestAppendStoragePutDirPath(c *C) { - rootDir, err := makeTempTestDir() + rootDir, err := utils.MakeTempTestDir() c.Assert(err, IsNil) defer os.RemoveAll(rootDir) @@ -82,7 +79,7 @@ func (s *AppendStorageSuite) TestAppendStoragePutDirPath(c *C) { } func (s *AppendStorageSuite) TestSerialization(c *C) { - rootDir, err := makeTempTestDir() + rootDir, err := utils.MakeTempTestDir() c.Assert(err, IsNil) defer os.RemoveAll(rootDir) diff --git a/pkgs/storage/encodedstorage/encoded_storage_test.go b/pkgs/storage/encodedstorage/encoded_storage_test.go index b788eee22..9b235b0a6 100644 --- a/pkgs/storage/encodedstorage/encoded_storage_test.go +++ b/pkgs/storage/encodedstorage/encoded_storage_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/minio-io/minio/pkgs/storage" + "github.com/minio-io/minio/pkgs/utils" . "gopkg.in/check.v1" ) @@ -17,12 +18,8 @@ var _ = Suite(&EncodedStorageSuite{}) func Test(t *testing.T) { TestingT(t) } -func makeTempTestDir() (string, error) { - return ioutil.TempDir("/tmp", "minio-test-") -} - func (s *EncodedStorageSuite) TestFileStoragePutAtRootPath(c *C) { - rootDir, err := makeTempTestDir() + rootDir, err := utils.MakeTempTestDir() c.Assert(err, IsNil) defer os.RemoveAll(rootDir) @@ -44,7 +41,7 @@ func (s *EncodedStorageSuite) TestFileStoragePutAtRootPath(c *C) { } func (s *EncodedStorageSuite) TestFileStoragePutDirPath(c *C) { - rootDir, err := makeTempTestDir() + rootDir, err := utils.MakeTempTestDir() c.Assert(err, IsNil) defer os.RemoveAll(rootDir) @@ -73,7 +70,7 @@ func (s *EncodedStorageSuite) TestFileStoragePutDirPath(c *C) { } func (s *EncodedStorageSuite) TestObjectWithChunking(c *C) { - rootDir, err := makeTempTestDir() + rootDir, err := utils.MakeTempTestDir() c.Assert(err, IsNil) defer os.RemoveAll(rootDir) diff --git a/pkgs/storage/fsstorage/fs_storage_test.go b/pkgs/storage/fsstorage/fs_storage_test.go index 25cb4af5c..fc582fd35 100644 --- a/pkgs/storage/fsstorage/fs_storage_test.go +++ b/pkgs/storage/fsstorage/fs_storage_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/minio-io/minio/pkgs/storage" + "github.com/minio-io/minio/pkgs/utils" . "gopkg.in/check.v1" ) @@ -16,12 +17,8 @@ var _ = Suite(&fileSystemStorageSuite{}) func Test(t *testing.T) { TestingT(t) } -func makeTempTestDir() (string, error) { - return ioutil.TempDir("/tmp", "minio-test-") -} - func (s *fileSystemStorageSuite) TestfileStoragePutAtRootPath(c *C) { - rootDir, err := makeTempTestDir() + rootDir, err := utils.MakeTempTestDir() c.Assert(err, IsNil) defer os.RemoveAll(rootDir) diff --git a/pkgs/miniotest/helpers.go b/pkgs/utils/helpers.go similarity index 85% rename from pkgs/miniotest/helpers.go rename to pkgs/utils/helpers.go index 897d2f7bd..0b18ae6aa 100644 --- a/pkgs/miniotest/helpers.go +++ b/pkgs/utils/helpers.go @@ -1,4 +1,4 @@ -package miniotest +package utils import "io/ioutil"