-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
48 lines (38 loc) · 921 Bytes
/
main_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
package stitchdb
import (
"fmt"
"os"
"strconv"
"testing"
"time"
)
func setup() {
c, _ := NewConfig(Persist, DirPath("stitch/test/db/"), Sync(NONE), ManageFrequency(1*time.Second), Developer, PerformanceMonitor, BucketFileMultLimit(10))
s, _ := NewStitchDB(c)
s.Open()
opts, _ := NewBucketOptions(BTreeDegree(32), Geo)
s.CreateBucket("test", opts)
s.Update("test", func(t *Tx) error {
t.CreateIndex("value", INT_INDEX)
for i := 0; i < 256; i++ {
eopt, _ := NewEntryOptions()
e, _ := NewEntry("key-"+strconv.Itoa(i), "{ \"value\":\""+strconv.Itoa(256-i)+"\", \"coords\": ["+strconv.Itoa(i)+", "+strconv.Itoa(256-i)+"]}", true, eopt)
t.Set(e)
}
return nil
})
//time.Sleep(time.Second * 2)
s.Close()
}
func teardown() {
err := os.RemoveAll("stitch/")
if err != nil {
fmt.Println(err)
}
}
func TestMain(m *testing.M) {
setup()
retCode := m.Run()
teardown()
os.Exit(retCode)
}