From f9f7d24e5829cdd8fe330f4a03ad2118a1c26785 Mon Sep 17 00:00:00 2001 From: siddontang Date: Fri, 16 May 2014 10:36:18 +0800 Subject: [PATCH] add some db base test --- ledis/t_hash_test.go | 17 +++++++++++++++++ ledis/t_kv_test.go | 15 +++++++++++++++ ledis/t_list_test.go | 17 +++++++++++++++++ ledis/t_zset_test.go | 17 +++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 ledis/t_hash_test.go create mode 100644 ledis/t_kv_test.go create mode 100644 ledis/t_list_test.go create mode 100644 ledis/t_zset_test.go diff --git a/ledis/t_hash_test.go b/ledis/t_hash_test.go new file mode 100644 index 0000000..ed13f2b --- /dev/null +++ b/ledis/t_hash_test.go @@ -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) + } +} diff --git a/ledis/t_kv_test.go b/ledis/t_kv_test.go new file mode 100644 index 0000000..f041b43 --- /dev/null +++ b/ledis/t_kv_test.go @@ -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) + } +} diff --git a/ledis/t_list_test.go b/ledis/t_list_test.go new file mode 100644 index 0000000..056602e --- /dev/null +++ b/ledis/t_list_test.go @@ -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) + } +} diff --git a/ledis/t_zset_test.go b/ledis/t_zset_test.go new file mode 100644 index 0000000..fcbe32a --- /dev/null +++ b/ledis/t_zset_test.go @@ -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) + } +}