Comparison

spec/core_configmanager_spec.lua @ 8236:4878e4159e12

Port tests to the `busted` test runner
author Waqas Hussain <waqas20@gmail.com>
date Fri, 15 Sep 2017 17:07:57 -0400
child 9168:29de7ad20250
comparison
equal deleted inserted replaced
8235:7d9a2c200736 8236:4878e4159e12
1
2 local configmanager = require "core.configmanager";
3
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(configmanager.get("example.com", "testkey"), 123, "Retrieving a set key");
9
10 configmanager.set("*", "testkey1", 321);
11 assert.are.equal(configmanager.get("*", "testkey1"), 321, "Retrieving a set global key");
12 assert.are.equal(configmanager.get("example.com", "testkey1"), 321, "Retrieving a set key of undefined host, of which only a globally set one exists");
13
14 configmanager.set("example.com", ""); -- Creates example.com host in config
15 assert.are.equal(configmanager.get("example.com", "testkey1"), 321, "Retrieving a set key, of which only a globally set one exists");
16
17 assert.are.equal(configmanager.get(), nil, "No parameters to get()");
18 assert.are.equal(configmanager.get("undefined host"), nil, "Getting for undefined host");
19 assert.are.equal(configmanager.get("undefined host", "undefined key"), nil, "Getting for undefined host & key");
20 end);
21 end);
22
23 describe("#set()", function()
24 it("should work", function()
25 assert.are.equal(configmanager.set("*"), false, "Set with no key");
26
27 assert.are.equal(configmanager.set("*", "set_test", "testkey"), true, "Setting a nil global value");
28 assert.are.equal(configmanager.set("*", "set_test", "testkey", 123), true, "Setting a global value");
29 end);
30 end);
31 end);