-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest-redis.lua
64 lines (55 loc) · 1.52 KB
/
test-redis.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
local u = require('luaunit')
local l = require("launchdarkly_server_sdk")
local r = require("launchdarkly_server_sdk_redis")
TestAll = {}
function makeTestClient()
return l.clientInit("sdk-test", 0, {
dataSystem = {
enabled = true,
lazyLoad = {
cacheRefreshMilliseconds = 1000,
source = r.makeRedisSource('redis://localhost:1234', 'test-prefix')
},
},
events = {
enabled = false
},
logging = {
basic = {
tag = "LaunchDarklyLua",
level = "warn"
}
}
})
end
local context = l.makeContext({
user = {
key = "alice"
}
})
function TestAll:tearDown()
collectgarbage("collect")
end
function TestAll:testInvalidRedisArguments()
u.assertErrorMsgContains('invalid URI', r.makeRedisSource, 'not a uri', 'test-prefix')
end
function TestAll:testVariationWithRedisSource()
local e = false
u.assertEquals(e, makeTestClient():boolVariation(context, "test", e))
end
function TestAll:testVariationDetailWithRedisSource()
local e = {
value = true,
reason = {
kind = "ERROR",
errorKind = "CLIENT_NOT_READY",
inExperiment = false
}
}
u.assertEquals(makeTestClient():boolVariationDetail(context, "test", true), e)
end
function TestAll:testAllFlags()
u.assertEquals(makeTestClient():allFlags(context), {})
end
local runner = u.LuaUnit.new()
os.exit(runner:runSuite())