fix issue in unit test case for gkvdb
@@ -25,13 +25,16 @@ import (
func Test_New(t *testing.T) {
gtest.Case(t, func() {
- path := "/tmp/gkvdb/" + gconv.String(gtime.Nanosecond())
+ name := gconv.String(gtime.Nanosecond())
+ path := "/tmp/gkvdb/" + name
key := []byte("key")
value := []byte("value")
- db := gkvdb.Instance()
- db.SetPath(path)
- err := db.Set(key, value)
+ db := gkvdb.Instance(name)
+ err := db.SetPath(path)
+ gtest.Assert(err, nil)
+
+ err = db.Set(key, value)
gtest.Assert(err, nil)
gtest.Assert(db.Get(key), value)
@@ -42,26 +45,31 @@ func Test_New(t *testing.T) {
func Test_Set(t *testing.T) {
gtest.Case(t, func() {
- path := "/tmp/gkvdb/" + gconv.String(gtime.Nanosecond())
+ name := gconv.String(gtime.Nanosecond())
+ path := "/tmp/gkvdb/" + name
key := []byte("key")
value := []byte("value")
- db := gkvdb.Instance()
- db.SetPath(path)
- err := db.Set(key, value, 100*time.Millisecond)
+ db := gkvdb.Instance(name)
+ err := db.SetPath(path)
+ gtest.Assert(err, nil)
+
+ err = db.Set(key, value, 1000*time.Millisecond)
gtest.Assert(err, nil)
gtest.Assert(db.Get(key), value)
- time.Sleep(200 * time.Millisecond)
+ time.Sleep(1500 * time.Millisecond)
gtest.Assert(db.Get(key), nil)
})
}
func Test_Iterate(t *testing.T) {
gtest.Case(t, func() {
- path := "/tmp/gkvdb/" + gconv.String(gtime.Nanosecond())
- db := gkvdb.Instance()
- db.SetPath(path)
+ name := gconv.String(gtime.Nanosecond())
+ path := "/tmp/gkvdb/" + name
+ db := gkvdb.Instance(name)
+ err := db.SetPath(path)
+ gtest.Assert(err, nil)
strArray := garray.NewSortedStringArray()
strArrayReverse := garray.NewSortedStringArrayComparator(func(a, b string) int {
