Merge pull request #58 from fkautz/pr_out_adding_initial_test_suites
This commit is contained in:
commit
ef9968160e
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
**/*.swp
|
||||
cover.out
|
||||
*~
|
||||
minio
|
||||
minio
|
||||
**/*.test
|
||||
|
|
24
pkg/storage/inmemory/inmemory_test.go
Normal file
24
pkg/storage/inmemory/inmemory_test.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package inmemory
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
mstorage "github.com/minio-io/minio/pkg/storage"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
func Test(t *testing.T) { TestingT(t) }
|
||||
|
||||
type MySuite struct{}
|
||||
|
||||
var _ = Suite(&MySuite{})
|
||||
|
||||
func (s *MySuite) TestAPISuite(c *C) {
|
||||
create := func() mstorage.Storage {
|
||||
_, _, store := Start()
|
||||
return store
|
||||
}
|
||||
|
||||
mstorage.APITestSuite(c, create)
|
||||
}
|
67
pkg/storage/storage_api_suite.go
Normal file
67
pkg/storage/storage_api_suite.go
Normal file
|
@ -0,0 +1,67 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
func APITestSuite(c *C, create func() Storage) {
|
||||
testCreateBucket(c, create)
|
||||
testMultipleObjectCreation(c, create)
|
||||
testPaging(c, create)
|
||||
testObjectOverwriteFails(c, create)
|
||||
testNonExistantBucketOperations(c, create)
|
||||
}
|
||||
|
||||
func testCreateBucket(c *C, create func() Storage) {
|
||||
// test create bucket
|
||||
// test bucket exists
|
||||
// test no objects exist
|
||||
// 2x
|
||||
}
|
||||
|
||||
func testMultipleObjectCreation(c *C, create func() Storage) {
|
||||
objects := make(map[string][]byte)
|
||||
storage := create()
|
||||
storage.StoreBucket("bucket")
|
||||
for i := 0; i < 10; i++ {
|
||||
randomPerm := rand.Perm(10)
|
||||
randomString := ""
|
||||
for _, num := range randomPerm {
|
||||
randomString = randomString + strconv.Itoa(num)
|
||||
}
|
||||
key := "obj" + strconv.Itoa(i)
|
||||
objects[key] = []byte(randomString)
|
||||
err := storage.StoreObject("bucket", key, bytes.NewBufferString(randomString))
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
// ensure no duplicates
|
||||
etags := make(map[string]string)
|
||||
for key, value := range objects {
|
||||
var byteBuffer bytes.Buffer
|
||||
storage.CopyObjectToWriter(&byteBuffer, "bucket", key)
|
||||
c.Assert(bytes.Equal(value, byteBuffer.Bytes()), Equals, true)
|
||||
|
||||
metadata, err := storage.GetObjectMetadata("bucket", key)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(metadata.Size, Equals, len(value))
|
||||
|
||||
_, ok := etags[metadata.ETag]
|
||||
c.Assert(ok, Equals, false)
|
||||
etags[metadata.ETag] = metadata.ETag
|
||||
}
|
||||
}
|
||||
|
||||
func testPaging(c *C, create func() Storage) {
|
||||
}
|
||||
|
||||
func testObjectOverwriteFails(c *C, create func() Storage) {
|
||||
// test overwriting object fails
|
||||
}
|
||||
func testNonExistantBucketOperations(c *C, create func() Storage) {
|
||||
// test writing object in non-existant bucket fails
|
||||
}
|
|
@ -289,6 +289,14 @@ func (s *MySuite) TestShouldNotBeAbleToCreateObjectInNonexistantBucket(c *C) {
|
|||
// TODO Implement
|
||||
}
|
||||
|
||||
func (s *MySuite) TestHeadOnObject(c *C) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
func (s *MySuite) TestDateFormat(c *C) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
func verifyHeaders(c *C, header http.Header, date time.Time, size int, contentType string, etag string) {
|
||||
// Verify date
|
||||
c.Assert(header["Last-Modified"][0], Equals, date.Format(time.RFC1123))
|
||||
|
@ -302,7 +310,3 @@ func verifyHeaders(c *C, header http.Header, date time.Time, size int, contentTy
|
|||
// verify etag
|
||||
c.Assert(header["Etag"][0], Equals, etag)
|
||||
}
|
||||
|
||||
// Test date format
|
||||
|
||||
// Test HEAD
|
||||
|
|
Loading…
Reference in a new issue