-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpfftdb_test.go
76 lines (66 loc) · 1.26 KB
/
pfftdb_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
70
71
72
73
74
75
76
package pfftdb
import (
"fmt"
"log"
"os"
"testing"
)
const (
DBNAME = "test"
DBUSER = ""
DBPASS = ""
ENV = "testing"
TESTGRAPH = "test"
TESTGRAPH2 = "test2"
)
var (
DBPATH = "localhost"
APIPORT = "9998"
goPath = fmt.Sprintf("%s", os.Getenv("GOPATH"))
dbType = "mongo"
webDir = ""
//webDir = goPath + "/src/pfftdb/web"
STORE *Store
GRPH *Graph
GRPH2 *Graph // so far only used for graph_test TestMerge
TESTAPI *API
)
func init() {
var err error
dbpath := os.Getenv("DBPATH")
if dbpath != "" {
DBPATH = dbpath
}
apiport := os.Getenv("APIPORT")
if dbpath != "" {
APIPORT = apiport
}
STORE, err = New(APIPORT, ENV, dbType, DBPATH, DBNAME, DBUSER, DBPASS, TESTGRAPH, webDir)
if err != nil {
log.Fatal(err)
}
TESTAPI = STORE.API
var ok bool
GRPH, ok = STORE.Driver.Graph(TESTGRAPH)
if !ok {
log.Fatal("couldn't get graph")
}
GRPH2, err = STORE.Driver.Create(TESTGRAPH2)
if err != nil {
log.Fatal("couldn't create graph2")
}
}
func TestNewDriver(t *testing.T) {
dbConf := &DBConf{Hosts: DBPATH}
_, err := NewDriver("mongo", dbConf)
if err != nil {
t.Fatal(err)
}
_, err = NewDriver("fake", dbConf)
if err == nil {
t.Fatal("should get error")
}
}
func TestCloseStore(t *testing.T) {
//store.Close()
}