mirror of
https://github.com/pgsty/minio.git
synced 2026-07-22 21:50:22 +03:00
Adding bucket management system with in memory storage driver
This commit is contained in:
+77
-1
@@ -1,6 +1,7 @@
|
||||
package minio
|
||||
|
||||
import (
|
||||
. "gopkg.in/check.v1"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -8,7 +9,13 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPrintsGateway(t *testing.T) {
|
||||
type MySuite struct{}
|
||||
|
||||
var _ = Suite(&MySuite{})
|
||||
|
||||
func Test(t *testing.T) { TestingT(t) }
|
||||
|
||||
func (s *MySuite) TestPrintsGateway(c *C) {
|
||||
server := httptest.NewServer(http.HandlerFunc(GatewayHandler))
|
||||
defer server.Close()
|
||||
res, err := http.Get(server.URL)
|
||||
@@ -25,3 +32,72 @@ func TestPrintsGateway(t *testing.T) {
|
||||
log.Fatal("Expected 'Gateway', Received '" + bodyString + "'")
|
||||
}
|
||||
}
|
||||
|
||||
type TestContext struct{}
|
||||
|
||||
func (s *MySuite) TestBucketCreation(c *C) {
|
||||
requestBucketChan := make(chan BucketRequest)
|
||||
defer close(requestBucketChan)
|
||||
go SynchronizedBucketService(requestBucketChan)
|
||||
context := TestContext{}
|
||||
|
||||
var bucketA1 Bucket
|
||||
callback := make(chan Bucket)
|
||||
requestBucketChan <- BucketRequest{
|
||||
name: "bucketA",
|
||||
context: context,
|
||||
callback: callback,
|
||||
}
|
||||
bucketA1 = <-callback
|
||||
c.Assert(bucketA1.GetName(context), Equals, "bucketA")
|
||||
|
||||
var bucketA2 Bucket
|
||||
callback = make(chan Bucket)
|
||||
requestBucketChan <- BucketRequest{
|
||||
name: "bucketA",
|
||||
context: context,
|
||||
callback: callback,
|
||||
}
|
||||
bucketA2 = <-callback
|
||||
c.Assert(bucketA2.GetName(context), Equals, "bucketA")
|
||||
|
||||
c.Assert(bucketA1, DeepEquals, bucketA2)
|
||||
|
||||
var bucketB Bucket
|
||||
callback = make(chan Bucket)
|
||||
requestBucketChan <- BucketRequest{
|
||||
name: "bucketB",
|
||||
context: context,
|
||||
callback: callback,
|
||||
}
|
||||
bucketB = <-callback
|
||||
c.Assert(bucketB.GetName(context), Equals, "bucketB")
|
||||
}
|
||||
|
||||
func (s *MySuite) TestBucketOperations(c *C) {
|
||||
requestBucketChan := make(chan BucketRequest)
|
||||
defer close(requestBucketChan)
|
||||
go SynchronizedBucketService(requestBucketChan)
|
||||
context := TestContext{}
|
||||
|
||||
callback := make(chan Bucket)
|
||||
requestBucketChan <- BucketRequest{
|
||||
name: "bucket",
|
||||
context: context,
|
||||
callback: callback,
|
||||
}
|
||||
|
||||
bucket := <-callback
|
||||
c.Assert(bucket.GetName(context), Equals, "bucket")
|
||||
|
||||
nilResult, err := bucket.Get(context, "foo")
|
||||
c.Assert(nilResult, IsNil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
err = bucket.Put(context, "foo", []byte("bar"))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
barResult, err := bucket.Get(context, "foo")
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(string(barResult), Equals, "bar")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user