-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbucket_test.go
More file actions
44 lines (37 loc) · 1.01 KB
/
bucket_test.go
File metadata and controls
44 lines (37 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package storage
import (
"errors"
"testing"
"github.com/arschles/assert"
s3 "github.com/minio/minio-go"
)
const (
bucketName = "mybucket"
)
type bucketCreate struct {
name string
acl s3.BucketACL
loc string
}
func TestCreateBucketSuccess(t *testing.T) {
creator := &FakeBucketCreator{
Fn: func(name string, acl s3.BucketACL, location string) error {
return nil
},
}
assert.NoErr(t, CreateBucket(creator, bucketName))
assert.Equal(t, len(creator.Calls), 1, "number of calls to MakeBucket")
assert.Equal(t, creator.Calls[0].BucketName, bucketName, "bucket name")
assert.Equal(t, creator.Calls[0].ACL, ACLPublicRead, "bucket ACL")
assert.Equal(t, creator.Calls[0].Location, "", "bucket location")
}
func TestCreateBucketFailure(t *testing.T) {
err := errors.New("test err")
creator := &FakeBucketCreator{
Fn: func(string, s3.BucketACL, string) error {
return err
},
}
assert.Err(t, CreateBucket(creator, bucketName), err)
assert.Equal(t, len(creator.Calls), 1, "number of calls to MakeBucket")
}