support multi transaction

This commit is contained in:
hdt3213
2021-05-31 21:20:33 +08:00
parent 9d03314359
commit 67c385ee4a
50 changed files with 1919 additions and 1122 deletions

View File

@@ -9,32 +9,32 @@ import (
)
func TestPing(t *testing.T) {
actual := Ping(testDB, utils.ToBytesList())
actual := Ping(testDB, utils.ToCmdLine())
asserts.AssertStatusReply(t, actual, "PONG")
val := utils.RandString(5)
actual = Ping(testDB, utils.ToBytesList(val))
actual = Ping(testDB, utils.ToCmdLine(val))
asserts.AssertStatusReply(t, actual, val)
actual = Ping(testDB, utils.ToBytesList(val, val))
actual = Ping(testDB, utils.ToCmdLine(val, val))
asserts.AssertErrReply(t, actual, "ERR wrong number of arguments for 'ping' command")
}
func TestAuth(t *testing.T) {
passwd := utils.RandString(10)
c := &connection.FakeConn{}
ret := testDB.Exec(c, utils.ToBytesList("AUTH"))
ret := testDB.Exec(c, utils.ToCmdLine("AUTH"))
asserts.AssertErrReply(t, ret, "ERR wrong number of arguments for 'auth' command")
ret = testDB.Exec(c, utils.ToBytesList("AUTH", passwd))
ret = testDB.Exec(c, utils.ToCmdLine("AUTH", passwd))
asserts.AssertErrReply(t, ret, "ERR Client sent AUTH, but no password is set")
config.Properties.RequirePass = passwd
defer func() {
config.Properties.RequirePass = ""
}()
ret = testDB.Exec(c, utils.ToBytesList("AUTH", passwd+"wrong"))
ret = testDB.Exec(c, utils.ToCmdLine("AUTH", passwd+"wrong"))
asserts.AssertErrReply(t, ret, "ERR invalid password")
ret = testDB.Exec(c, utils.ToBytesList("PING"))
ret = testDB.Exec(c, utils.ToCmdLine("PING"))
asserts.AssertErrReply(t, ret, "NOAUTH Authentication required")
ret = testDB.Exec(c, utils.ToBytesList("AUTH", passwd))
ret = testDB.Exec(c, utils.ToCmdLine("AUTH", passwd))
asserts.AssertStatusReply(t, ret, "OK")
}