Skip to content

Commit 5349d50

Browse files
author
Aaron Schlesinger
committed
fix(pkg/gitreceive/storage/bucket_test.go): add test for CreateBucket
1 parent 4075413 commit 5349d50

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package storage
2+
3+
import (
4+
"errors"
5+
"testing"
6+
7+
"github.com/arschles/assert"
8+
s3 "github.com/minio/minio-go"
9+
)
10+
11+
const (
12+
bucketName = "mybucket"
13+
)
14+
15+
type bucketCreate struct {
16+
name string
17+
acl s3.BucketACL
18+
loc string
19+
}
20+
21+
func TestCreateBucketSuccess(t *testing.T) {
22+
var res bucketCreate
23+
creator := FakeBucketCreator(func(name string, acl s3.BucketACL, location string) error {
24+
res = bucketCreate{name: name, acl: acl, loc: location}
25+
return nil
26+
})
27+
28+
assert.NoErr(t, CreateBucket(creator, bucketName))
29+
assert.Equal(t, res.name, bucketName, "bucket name")
30+
assert.Equal(t, res.acl, ACLPublicRead, "bucket ACL")
31+
assert.Equal(t, res.loc, "", "bucket location")
32+
}
33+
34+
func TestCreateBucketFailure(t *testing.T) {
35+
err := errors.New("test err")
36+
creator := FakeBucketCreator(func(string, s3.BucketACL, string) error {
37+
return err
38+
})
39+
assert.Err(t, CreateBucket(creator, bucketName), err)
40+
}

0 commit comments

Comments
 (0)