-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
43 lines (39 loc) · 932 Bytes
/
example_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
package gomongoengine
import (
"context"
"testing"
"time"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
//example struct A
type A struct {
Name string
}
//TestConnection
func TestConnection(t *testing.T) {
client, _ := mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27027"))
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
err := client.Connect(ctx)
t.Error(err)
collection := client.Database("testing").Collection("numbers")
_, err = collection.InsertOne(ctx, A{Name: "sdklfjk"})
t.Error(err)
// time.Sleep(10 * time.Second)
_, err = collection.InsertOne(ctx, A{Name: "sss"})
t.Error(err)
// time.Sleep(10 * time.Second)
_, err = collection.InsertOne(ctx, A{Name: "qqq"})
t.Error(err)
}
func TestType(t *testing.T) {
type Empt struct {
S int32
FN string
CCRE A
CCREP *A
}
e := Empt{S: 0}
t.Log(e)
t.Error("todo")
}