forked from rai-project/model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model_test.go
49 lines (39 loc) · 868 Bytes
/
model_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
package model
import (
"os"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/c3sr/config"
mongodb "github.com/c3sr/database/mongodb"
"gopkg.in/mgo.v2/bson"
)
func TestMain(m *testing.M) {
config.Init(
config.AppName("rai"),
config.VerboseMode(true),
config.DebugMode(true),
)
os.Exit(m.Run())
}
func TestConnection(t *testing.T) {
db, err := mongodb.NewDatabase(config.App.Name)
assert.NoError(t, err)
assert.NotEmpty(t, db)
defer db.Close()
}
func TestInsertRanking(t *testing.T) {
db, err := mongodb.NewDatabase(config.App.Name)
assert.NoError(t, err)
assert.NotEmpty(t, db)
defer db.Close()
tbl, err := mongodb.NewTable(db, "test")
assert.NoError(t, err)
assert.NotEmpty(t, tbl)
// tbl.Create(nil)
err = tbl.Insert(Base{
ID: bson.NewObjectId(),
CreatedAt: time.Now(),
})
assert.NoError(t, err)
}