-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys_test.go
43 lines (32 loc) · 1010 Bytes
/
keys_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package redisLuaScriptUtils_test
import (
"testing"
redisLuaScriptUtils "github.com/zavitax/redis-lua-script-utils-go"
)
func TestStaticKeys(t *testing.T) {
key := redisLuaScriptUtils.NewStaticKey("key", "value")
if key.Key() != "key" {
t.Error("key.Key() return value should be 'key'")
return
}
argsMap := make(redisLuaScriptUtils.RedisScriptArguments, 0)
if key.Value(&argsMap) != "value" {
t.Error("key.Value() return value should be 'value'")
return
}
}
func TestDynamicKeys(t *testing.T) {
key := redisLuaScriptUtils.NewDynamicKey("key", func(args *redisLuaScriptUtils.RedisScriptArguments) string {
return (*args)["arg1"].(string)
})
if key.Key() != "key" {
t.Error("key.Key() return value should be 'key'")
return
}
argsMap := make(redisLuaScriptUtils.RedisScriptArguments, 0)
argsMap["arg1"] = "expected_argument_value"
if key.Value(&argsMap) != "expected_argument_value" {
t.Error("key.Value() return value should be 'expected_argument_value'")
return
}
}