Skip to content

Commit

Permalink
Add failing test for script with arguments
Browse files Browse the repository at this point in the history
This is failing bc I misunderstood `eval` in Redis

Eval is: EVAL script numkeys key key key arg arg arg

Keys here is not the NAME of the argument, as I thought, but rather an
input parameter in full

There's no named arguments in Redis. I assumed that by reading examples
from the C# API Client in the Rate Limiting implementation docs.

Args and Keys are referenced like KEYS[1] KEYS[2] KEYS [3] and ARGV[1]
ARGV[2] ARGV[3]

Let's fix that in the next few commits
  • Loading branch information
omnibs committed May 22, 2024
1 parent 346d758 commit 4e3fb2a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nri-redis/test/Spec/Redis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,13 @@ queryTests redisHandler =
Test.test "eval runs and returns something" <| \() -> do
let script = [Redis.script|return 1|]
result <- Redis.eval intJsonApi script |> Redis.query testNS |> Expect.succeeds
Expect.equal result 1,
Test.test "eval with arguments runs and returns something" <| \() -> do
let script = [Redis.script|
local a = ${Redis.Key "hi"}
local b = ${Redis.Literal "hello"}
return 1|]
result <- Redis.eval intJsonApi script |> Redis.query testNS |> Expect.succeeds
Expect.equal result 1
]
where
Expand Down

0 comments on commit 4e3fb2a

Please sign in to comment.