-
Notifications
You must be signed in to change notification settings - Fork 8
/
collection_creator_test.go
47 lines (38 loc) · 1.17 KB
/
collection_creator_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
// Copyright Kuei-chun Chen, 2022-present. All rights reserved.
package hummingbird
import (
"context"
"testing"
"github.com/simagix/keyhole/mdb"
"go.mongodb.org/mongo-driver/mongo/options"
)
func TestCollectionCreator(t *testing.T) {
ctx := context.Background()
dbName, collName := mdb.SplitNamespace(TestNS)
source, err := GetMongoClient(TestSourceURI)
assertEqual(t, nil, err)
src := source.Database(dbName).Collection(collName)
err = src.Drop(ctx)
assertEqual(t, nil, err)
target, err := GetMongoClient(TestTargetURI)
assertEqual(t, nil, err)
tgt := target.Database(dbName).Collection(collName)
err = tgt.Drop(ctx)
assertEqual(t, nil, err)
locale := "zh_Hant"
collation := options.Collation{Locale: locale}
collOpts := options.CreateCollection()
collOpts.SetCollation(&collation)
err = source.Database(dbName).CreateCollection(ctx, collName, collOpts)
assertEqual(t, nil, err)
filename := "testdata/config.json"
inst, err := NewMigratorInstance(filename)
assertEqual(t, nil, err)
inst.DropCollections()
err = CollectionCreator()
assertEqual(t, nil, err)
inst.ResetIncludesTo(nil)
inst.DropCollections()
err = CollectionCreator()
assertEqual(t, nil, err)
}