Merge 0.10->0.11
[prosody.git] / spec / core_configmanager_spec.lua
blobafb7d492c04ed8395ec137b9e1e5475d5358dcd9
2 local configmanager = require "core.configmanager";
4 describe("core.configmanager", function()
5 describe("#get()", function()
6 it("should work", function()
7 configmanager.set("example.com", "testkey", 123);
8 assert.are.equal(123, configmanager.get("example.com", "testkey"), "Retrieving a set key");
10 configmanager.set("*", "testkey1", 321);
11 assert.are.equal(321, configmanager.get("*", "testkey1"), "Retrieving a set global key");
12 assert.are.equal(321, configmanager.get("example.com", "testkey1"), "Retrieving a set key of undefined host, of which only a globally set one exists");
14 configmanager.set("example.com", ""); -- Creates example.com host in config
15 assert.are.equal(321, configmanager.get("example.com", "testkey1"), "Retrieving a set key, of which only a globally set one exists");
17 assert.are.equal(nil, configmanager.get(), "No parameters to get()");
18 assert.are.equal(nil, configmanager.get("undefined host"), "Getting for undefined host");
19 assert.are.equal(nil, configmanager.get("undefined host", "undefined key"), "Getting for undefined host & key");
20 end);
21 end);
23 describe("#set()", function()
24 it("should work", function()
25 assert.are.equal(false, configmanager.set("*"), "Set with no key");
27 assert.are.equal(true, configmanager.set("*", "set_test", "testkey"), "Setting a nil global value");
28 assert.are.equal(true, configmanager.set("*", "set_test", "testkey", 123), "Setting a global value");
29 end);
30 end);
31 end);