-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathlungo_test.go
69 lines (58 loc) · 2.14 KB
/
lungo_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
60
61
62
63
64
65
66
67
68
69
package lungo
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"go.mongodb.org/mongo-driver/mongo"
)
var mongoReplacements = map[string]string{
"*mongo.Client": "lungo.IClient",
"*mongo.Database": "lungo.IDatabase",
"*mongo.Collection": "lungo.ICollection",
"*mongo.Cursor": "lungo.ICursor",
"*mongo.SingleResult": "lungo.ISingleResult",
"mongo.IndexView": "lungo.IIndexView",
"*mongo.ChangeStream": "lungo.IChangeStream",
"mongo.Session": "lungo.ISession",
"mongo.SessionContext": "lungo.ISessionContext",
}
func TestClientInterface(t *testing.T) {
a := reflect.TypeOf((*IClient)(nil)).Elem()
b := reflect.TypeOf(&mongo.Client{})
assert.Equal(t, methods(a, nil), methods(b, mongoReplacements))
}
func TestDatabaseInterface(t *testing.T) {
a := reflect.TypeOf((*IDatabase)(nil)).Elem()
b := reflect.TypeOf(&mongo.Database{})
assert.Equal(t, methods(a, nil), methods(b, mongoReplacements))
}
func TestCollectionInterface(t *testing.T) {
a := reflect.TypeOf((*ICollection)(nil)).Elem()
b := reflect.TypeOf(&mongo.Collection{})
assert.Equal(t, methods(a, nil), methods(b, mongoReplacements))
}
func TestCursorInterface(t *testing.T) {
a := reflect.TypeOf((*ICursor)(nil)).Elem()
b := reflect.TypeOf(&mongo.Cursor{})
assert.Equal(t, methods(a, nil), methods(b, mongoReplacements))
}
func TestSingleResultInterface(t *testing.T) {
a := reflect.TypeOf((*ISingleResult)(nil)).Elem()
b := reflect.TypeOf(&mongo.SingleResult{})
assert.Equal(t, methods(a, nil), methods(b, mongoReplacements))
}
func TestIndexViewInterface(t *testing.T) {
a := reflect.TypeOf((*IIndexView)(nil)).Elem()
b := reflect.TypeOf(&mongo.IndexView{})
assert.Equal(t, methods(a, nil), methods(b, mongoReplacements))
}
func TestChangeStreamInterface(t *testing.T) {
a := reflect.TypeOf((*IChangeStream)(nil)).Elem()
b := reflect.TypeOf(&mongo.ChangeStream{})
assert.Equal(t, methods(a, nil), methods(b, mongoReplacements))
}
func TestSessionInterface(t *testing.T) {
a := reflect.TypeOf((*ISession)(nil)).Elem()
b := reflect.TypeOf((*mongo.Session)(nil)).Elem()
assert.Equal(t, methods(a, nil), methods(b, mongoReplacements))
}