aboutsummaryrefslogtreecommitdiffstats
path: root/spec/core_configmanager_spec.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2017-09-15 17:07:57 -0400
committerWaqas Hussain <waqas20@gmail.com>2017-09-15 17:07:57 -0400
commit67293fc09fea737de37a2fea7b211aa44695b5bf (patch)
treeb5cd2d09f0ee7e1e9e13feec26defe4f7d9f5003 /spec/core_configmanager_spec.lua
parent4c6c255113df008869577d4ec0291ff880b1273c (diff)
downloadprosody-67293fc09fea737de37a2fea7b211aa44695b5bf.tar.gz
prosody-67293fc09fea737de37a2fea7b211aa44695b5bf.zip
Port tests to the `busted` test runner
Diffstat (limited to 'spec/core_configmanager_spec.lua')
-rw-r--r--spec/core_configmanager_spec.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/core_configmanager_spec.lua b/spec/core_configmanager_spec.lua
new file mode 100644
index 00000000..b68d2756
--- /dev/null
+++ b/spec/core_configmanager_spec.lua
@@ -0,0 +1,31 @@
+
+local configmanager = require "core.configmanager";
+
+describe("core.configmanager", function()
+ describe("#get()", function()
+ it("should work", function()
+ configmanager.set("example.com", "testkey", 123);
+ assert.are.equal(configmanager.get("example.com", "testkey"), 123, "Retrieving a set key");
+
+ configmanager.set("*", "testkey1", 321);
+ assert.are.equal(configmanager.get("*", "testkey1"), 321, "Retrieving a set global key");
+ assert.are.equal(configmanager.get("example.com", "testkey1"), 321, "Retrieving a set key of undefined host, of which only a globally set one exists");
+
+ configmanager.set("example.com", ""); -- Creates example.com host in config
+ assert.are.equal(configmanager.get("example.com", "testkey1"), 321, "Retrieving a set key, of which only a globally set one exists");
+
+ assert.are.equal(configmanager.get(), nil, "No parameters to get()");
+ assert.are.equal(configmanager.get("undefined host"), nil, "Getting for undefined host");
+ assert.are.equal(configmanager.get("undefined host", "undefined key"), nil, "Getting for undefined host & key");
+ end);
+ end);
+
+ describe("#set()", function()
+ it("should work", function()
+ assert.are.equal(configmanager.set("*"), false, "Set with no key");
+
+ assert.are.equal(configmanager.set("*", "set_test", "testkey"), true, "Setting a nil global value");
+ assert.are.equal(configmanager.set("*", "set_test", "testkey", 123), true, "Setting a global value");
+ end);
+ end);
+end);