From e9bca10875e5132b9fa46970ff570f59d1afbf38 Mon Sep 17 00:00:00 2001 From: Nikolay Turpitko Date: Thu, 21 Jan 2016 17:46:44 +0600 Subject: [PATCH] Convert commands to lowercase before use as a key in the map --- server/client.go | 3 +++ server/script_test.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/server/client.go b/server/client.go index 9d6b17f..990f7fd 100644 --- a/server/client.go +++ b/server/client.go @@ -4,6 +4,7 @@ import ( "bytes" // "fmt" "io" + "strings" "time" "github.com/siddontang/go/sync2" @@ -107,6 +108,8 @@ func (c *client) perform() { start := time.Now() + c.cmd = strings.ToLower(c.cmd) + if len(c.cmd) == 0 { err = ErrEmptyCommand } else if exeCmd, ok := regCmds[c.cmd]; !ok { diff --git a/server/script_test.go b/server/script_test.go index cc19eb7..0446bb7 100644 --- a/server/script_test.go +++ b/server/script_test.go @@ -101,6 +101,10 @@ var testScript4 = ` ledis.call("set", 2, "b") ` +var testScript5 = ` + return ledis.call("PING") +` + func TestLuaCall(t *testing.T) { cfg := config.NewConfigDefault() cfg.Addr = ":11188" @@ -173,5 +177,15 @@ func TestLuaCall(t *testing.T) { t.Fatal(string(v)) } + err = app.script.l.DoString(testScript5) + if err != nil { + t.Fatal(err) + } + + v = luaReplyToLedisReply(l) + if vv := v.(string); vv != "PONG" { + t.Fatal(fmt.Sprintf("%v %T", v, v)) + } + luaClient.db = nil }