add some db base test

This commit is contained in:
siddontang 2014-05-16 10:36:18 +08:00
parent 6152d75160
commit f9f7d24e58
4 changed files with 66 additions and 0 deletions

17
ledis/t_hash_test.go Normal file
View File

@ -0,0 +1,17 @@
package ledis
import (
"testing"
)
func TestDBHash(t *testing.T) {
db := getTestDB()
key := []byte("testdb_hash_a")
if n, err := db.HSet(key, []byte("a"), []byte("hello world")); err != nil {
t.Fatal(err)
} else if n != 1 {
t.Fatal(n)
}
}

15
ledis/t_kv_test.go Normal file
View File

@ -0,0 +1,15 @@
package ledis
import (
"testing"
)
func TestDBKV(t *testing.T) {
db := getTestDB()
key := []byte("testdb_kv_a")
if err := db.Set(key, []byte("hello world")); err != nil {
t.Fatal(err)
}
}

17
ledis/t_list_test.go Normal file
View File

@ -0,0 +1,17 @@
package ledis
import (
"testing"
)
func TestDBList(t *testing.T) {
db := getTestDB()
key := []byte("testdb_list_a")
if n, err := db.RPush(key, []byte("1"), []byte("2")); err != nil {
t.Fatal(err)
} else if n != 2 {
t.Fatal(n)
}
}

17
ledis/t_zset_test.go Normal file
View File

@ -0,0 +1,17 @@
package ledis
import (
"testing"
)
func TestDBZSet(t *testing.T) {
db := getTestDB()
key := []byte("testdb_zset_a")
if n, err := db.ZAdd(key, ScorePair{1, []byte("a")}, ScorePair{1, []byte("a")}); err != nil {
t.Fatal(err)
} else if n != 2 {
t.Fatal(n)
}
}