-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-incr-and-stor.lua
31 lines (23 loc) · 1.01 KB
/
test-incr-and-stor.lua
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
local call_redis_script = require "./harness";
describe("incr-and-stor", function()
-- Flush the database before running the tests
before_each(function()
redis.call('FLUSHDB')
end)
it("should add single items", function()
-- Call the incr-and-stor.lua script with the given keys and values
local result = call_redis_script('incr-and-stor.lua', { "counter", "hash" }, { "link1" });
assert.are.equals(1, result)
local hash = redis.call("HGETALL", "hash")
assert.are.same({ ["1"] = "link1" }, hash)
end)
it("should add multiple items", function()
-- Call the incr-and-stor.lua script with the given keys and values
local result = call_redis_script('incr-and-stor.lua', { "counter", "hash" }, { "link1" });
assert.are.equals(1, result)
result = call_redis_script('incr-and-stor.lua', { "counter", "hash" }, { "link2" });
assert.are.equals(2, result)
local hash = redis.call("HGETALL", "hash")
assert.are.same({ ["1"] = "link1", ["2"] = "link2" }, hash)
end)
end)