ledisdb/server/cmd_server_test.go

40 lines
626 B
Go
Raw Permalink Normal View History

package server
import (
"testing"
2015-05-04 17:42:28 +03:00
"github.com/siddontang/goredis"
)
2015-03-22 03:39:20 +03:00
func TestXSelect(t *testing.T) {
c1 := getTestConn()
defer c1.Close()
c2 := getTestConn()
defer c2.Close()
2015-03-22 03:39:20 +03:00
_, err := c1.Do("XSELECT", "1", "THEN", "SET", "tmp_select_key", "1")
if err != nil {
t.Fatal(err)
}
_, err = goredis.Int(c2.Do("GET", "tmp_select_key"))
if err != goredis.ErrNil {
t.Fatal(err)
}
2015-03-22 03:39:20 +03:00
n, _ := goredis.Int(c2.Do("XSELECT", "1", "THEN", "GET", "tmp_select_key"))
if n != 1 {
t.Fatal(n)
}
n, _ = goredis.Int(c2.Do("GET", "tmp_select_key"))
if n != 1 {
t.Fatal(n)
}
c1.Do("SELECT", 0)
c2.Do("SELECT", 0)
}