Software /
code /
prosody
Comparison
tests/test_core_configmanager.lua @ 5605:468d7a2f85ba
tests/test_core_configmanager.lua: Update to remove tests based on sections (now removed)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 18 May 2013 17:17:56 +0100 |
parent | 3540:bc139431830b |
child | 5776:bd0ff8ae98a8 |
comparison
equal
deleted
inserted
replaced
5604:6df0ec991f2e | 5605:468d7a2f85ba |
---|---|
7 -- | 7 -- |
8 | 8 |
9 | 9 |
10 | 10 |
11 function get(get, config) | 11 function get(get, config) |
12 config.set("example.com", "test", "testkey", 123); | 12 config.set("example.com", "testkey", 123); |
13 assert_equal(get("example.com", "test", "testkey"), 123, "Retrieving a set key"); | 13 assert_equal(get("example.com", "testkey"), 123, "Retrieving a set key"); |
14 | 14 |
15 config.set("*", "test", "testkey1", 321); | 15 config.set("*", "testkey1", 321); |
16 assert_equal(get("*", "test", "testkey1"), 321, "Retrieving a set global key"); | 16 assert_equal(get("*", "testkey1"), 321, "Retrieving a set global key"); |
17 assert_equal(get("example.com", "test", "testkey1"), 321, "Retrieving a set key of undefined host, of which only a globally set one exists"); | 17 assert_equal(get("example.com", "testkey1"), 321, "Retrieving a set key of undefined host, of which only a globally set one exists"); |
18 | 18 |
19 config.set("example.com", "test", ""); -- Creates example.com host in config | 19 config.set("example.com", ""); -- Creates example.com host in config |
20 assert_equal(get("example.com", "test", "testkey1"), 321, "Retrieving a set key, of which only a globally set one exists"); | 20 assert_equal(get("example.com", "testkey1"), 321, "Retrieving a set key, of which only a globally set one exists"); |
21 | 21 |
22 assert_equal(get(), nil, "No parameters to get()"); | 22 assert_equal(get(), nil, "No parameters to get()"); |
23 assert_equal(get("undefined host"), nil, "Getting for undefined host"); | 23 assert_equal(get("undefined host"), nil, "Getting for undefined host"); |
24 assert_equal(get("undefined host", "undefined section"), nil, "Getting for undefined host & section"); | 24 assert_equal(get("undefined host", "undefined key"), nil, "Getting for undefined host & key"); |
25 assert_equal(get("undefined host", "undefined section", "undefined key"), nil, "Getting for undefined host & section & key"); | |
26 | |
27 assert_equal(get("example.com", "undefined section", "testkey"), nil, "Defined host, undefined section"); | |
28 end | 25 end |
29 | 26 |
30 function set(set, u) | 27 function set(set, u) |
31 assert_equal(set("*"), false, "Set with no section/key"); | 28 assert_equal(set("*"), false, "Set with no key"); |
32 assert_equal(set("*", "set_test"), false, "Set with no key"); | |
33 | 29 |
34 assert_equal(set("*", "set_test", "testkey"), true, "Setting a nil global value"); | 30 assert_equal(set("*", "set_test", "testkey"), true, "Setting a nil global value"); |
35 assert_equal(set("*", "set_test", "testkey", 123), true, "Setting a global value"); | 31 assert_equal(set("*", "set_test", "testkey", 123), true, "Setting a global value"); |
36 end | 32 end |
37 | 33 |