2015-03-21 15:33:57 +03:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2015-05-04 17:42:28 +03:00
|
|
|
|
|
|
|
"github.com/siddontang/goredis"
|
2015-03-21 15:33:57 +03:00
|
|
|
)
|
|
|
|
|
2015-03-22 03:39:20 +03:00
|
|
|
func TestXSelect(t *testing.T) {
|
2015-03-21 15:33:57 +03:00
|
|
|
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")
|
2015-03-21 15:33:57 +03:00
|
|
|
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"))
|
2015-03-21 15:33:57 +03:00
|
|
|
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)
|
|
|
|
|
|
|
|
}
|