diff --git a/Makefile b/Makefile index 3ab2ff034..27aa61b49 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,8 @@ build-signify: cd pkgs/signify && make test: build-erasure build-signify - godep go test -race -coverprofile=cover.out github.com/minio-io/minio + godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkgs/storage + godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkgs/gateway install: build-erasure godep go install github.com/minio-io/minio/cmd/minio-encode diff --git a/gateway.go b/pkgs/gateway/gateway.go similarity index 96% rename from gateway.go rename to pkgs/gateway/gateway.go index 4a0b482fd..0025b0550 100644 --- a/gateway.go +++ b/pkgs/gateway/gateway.go @@ -1,13 +1,15 @@ -package minio +package gateway import ( "errors" "fmt" - "github.com/gorilla/mux" - "github.com/tchap/go-patricia/patricia" "io/ioutil" "net/http" "path" + + "github.com/gorilla/mux" + "github.com/minio-io/minio/pkgs/storage" + "github.com/tchap/go-patricia/patricia" ) // Stores system configuration, populated from CLI or test runner @@ -195,14 +197,14 @@ func InMemoryStorageDriver(bucket string, input chan ObjectRequest, config Gatew } func SimpleFileStorageDriver(bucket string, input chan ObjectRequest, config GatewayConfig) { - storage := FileStorage{ + fileStorage := storage.FileStorage{ RootDir: config.dataDir, } for request := range input { switch request.requestType { case "GET": objectPath := path.Join(bucket, request.path) - object, err := storage.Get(objectPath) + object, err := fileStorage.Get(objectPath) if err != nil { request.callback <- nil } else { @@ -210,7 +212,7 @@ func SimpleFileStorageDriver(bucket string, input chan ObjectRequest, config Gat } case "PUT": objectPath := path.Join(bucket, request.path) - storage.Put(objectPath, request.object) + fileStorage.Put(objectPath, request.object) request.callback <- nil default: request.callback <- errors.New("Unexpected message") diff --git a/gateway_test.go b/pkgs/gateway/gateway_test.go similarity index 96% rename from gateway_test.go rename to pkgs/gateway/gateway_test.go index 849fcd57a..ae9e6fede 100644 --- a/gateway_test.go +++ b/pkgs/gateway/gateway_test.go @@ -1,13 +1,15 @@ -package minio +package gateway import ( - "github.com/gorilla/mux" - . "gopkg.in/check.v1" "io/ioutil" "net/http" "net/http/httptest" "os" "strings" + + "github.com/gorilla/mux" + "github.com/minio-io/minio/pkgs/miniotest" + . "gopkg.in/check.v1" ) type GatewaySuite struct{} @@ -102,7 +104,7 @@ func (s *GatewaySuite) TestBucketCreation(c *C) { } func (s *GatewaySuite) TestInMemoryBucketOperations(c *C) { - simpleFileStorageRootDir, err := makeTempTestDir() + simpleFileStorageRootDir, err := miniotest.MakeTempTestDir() c.Assert(err, IsNil) defer os.RemoveAll(simpleFileStorageRootDir) configs := []GatewayConfig{ diff --git a/pkgs/miniotest/helpers.go b/pkgs/miniotest/helpers.go new file mode 100644 index 000000000..897d2f7bd --- /dev/null +++ b/pkgs/miniotest/helpers.go @@ -0,0 +1,7 @@ +package miniotest + +import "io/ioutil" + +func MakeTempTestDir() (string, error) { + return ioutil.TempDir("/tmp", "minio-test-") +} diff --git a/file_storage.go b/pkgs/storage/file_storage.go similarity index 96% rename from file_storage.go rename to pkgs/storage/file_storage.go index 03f51b5d5..46b832a45 100644 --- a/file_storage.go +++ b/pkgs/storage/file_storage.go @@ -1,4 +1,4 @@ -package minio +package storage import ( "io/ioutil" diff --git a/file_storage_test.go b/pkgs/storage/file_storage_test.go similarity index 98% rename from file_storage_test.go rename to pkgs/storage/file_storage_test.go index 7ef52cd52..9f1116f90 100644 --- a/file_storage_test.go +++ b/pkgs/storage/file_storage_test.go @@ -1,4 +1,4 @@ -package minio +package storage import ( . "gopkg.in/check.v1" diff --git a/storage.go b/pkgs/storage/storage.go similarity index 95% rename from storage.go rename to pkgs/storage/storage.go index 5892b2d33..14ff348de 100644 --- a/storage.go +++ b/pkgs/storage/storage.go @@ -1,4 +1,4 @@ -package minio +package storage import ( "fmt" diff --git a/storage_test.go b/pkgs/storage/storage_test.go similarity index 96% rename from storage_test.go rename to pkgs/storage/storage_test.go index 5f2c67135..8f8492a15 100644 --- a/storage_test.go +++ b/pkgs/storage/storage_test.go @@ -1,4 +1,4 @@ -package minio +package storage import ( "io/ioutil" diff --git a/setup_test.go b/setup_test.go deleted file mode 100644 index 9174d9647..000000000 --- a/setup_test.go +++ /dev/null @@ -1,8 +0,0 @@ -package minio - -import ( - . "gopkg.in/check.v1" - "testing" -) - -func Test(t *testing.T) { TestingT(t) }