forked from couchbase/gocb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bucket_collectionsmgr_test.go
59 lines (48 loc) · 1.43 KB
/
bucket_collectionsmgr_test.go
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package gocb
import (
"errors"
)
func (suite *IntegrationTestSuite) TestCollectionManagerCrud() {
suite.skipIfUnsupported(CollectionsFeature)
mgr := globalBucket.Collections()
err := mgr.CreateScope("testScope", nil)
if err != nil {
suite.T().Fatalf("Failed to create scope %v", err)
}
err = mgr.CreateScope("testScope", nil)
if !errors.Is(err, ErrScopeExists) {
suite.T().Fatalf("Expected create scope to error with ScopeExists but was %v", err)
}
err = mgr.CreateCollection(CollectionSpec{
Name: "testCollection",
ScopeName: "testScope",
}, nil)
if err != nil {
suite.T().Fatalf("Failed to create collection %v", err)
}
err = mgr.CreateCollection(CollectionSpec{
Name: "testCollection",
ScopeName: "testScope",
}, nil)
if !errors.Is(err, ErrCollectionExists) {
suite.T().Fatalf("Expected create collection to error with CollectionExists but was %v", err)
}
scopes, err := mgr.GetAllScopes(nil)
if err != nil {
suite.T().Fatalf("Failed to GetAllScopes %v", err)
}
if len(scopes) < 2 {
suite.T().Fatalf("Expected scopes to contain at least 2 scopes but was %v", scopes)
}
err = mgr.DropCollection(CollectionSpec{
Name: "testCollection",
ScopeName: "testScope",
}, nil)
if err != nil {
suite.T().Fatalf("Expected DropCollection to not error but was %v", err)
}
err = mgr.DropScope("testScope", nil)
if err != nil {
suite.T().Fatalf("Expected DropScope to not error but was %v", err)
}
}