-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdb_test.go
65 lines (52 loc) · 1.36 KB
/
db_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
package gitdb_test
import (
"reflect"
"testing"
"github.com/gogitdb/gitdb/v2"
)
func TestMigrate(t *testing.T) {
teardown := setup(t, nil)
defer teardown(t)
m := getTestMessageWithId(0)
if err := insert(m, false); err != nil {
t.Errorf("insert failed: %s", err)
}
m2 := &MessageV2{}
if err := testDb.Migrate(m, m2); err != nil {
t.Errorf("testDb.Migrate() returned error - %s", err)
}
}
func TestNewConfig(t *testing.T) {
cfg := gitdb.NewConfig(dbPath)
db, err := gitdb.Open(cfg)
if err != nil {
t.Errorf("gitdb.Open failed: %s", err)
}
if reflect.DeepEqual(db.Config(), cfg) {
t.Errorf("Config does not match. want: %v, got: %v", cfg, db.Config())
}
}
func TestNewConfigWithLocalDriver(t *testing.T) {
cfg := gitdb.NewConfigWithLocalDriver(dbPath)
db, err := gitdb.Open(cfg)
if err != nil {
t.Errorf("gitdb.Open failed: %s", err)
}
if reflect.DeepEqual(db.Config(), cfg) {
t.Errorf("Config does not match. want: %v, got: %v", cfg, db.Config())
}
}
func TestConfigValidate(t *testing.T) {
cfg := &gitdb.Config{}
if err := cfg.Validate(); err == nil {
t.Errorf("cfg.Validate should fail if DbPath is %s", cfg.DBPath)
}
}
func TestGetLastCommitTime(t *testing.T) {
teardown := setup(t, nil)
defer teardown(t)
_, err := testDb.GetLastCommitTime()
if err == nil {
t.Errorf("dbConn.GetLastCommitTime() returned error - %s", err)
}
}