util.dependencies: Not finding our own libraries is fatal
[prosody.git] / tests / test_core_configmanager.lua
1 -- Prosody IM v0.2
2 -- Copyright (C) 2008 Matthew Wild
3 -- Copyright (C) 2008 Waqas Hussain
4 -- 
5 -- This program is free software; you can redistribute it and/or
6 -- modify it under the terms of the GNU General Public License
7 -- as published by the Free Software Foundation; either version 2
8 -- of the License, or (at your option) any later version.
9 -- 
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 -- GNU General Public License for more details.
14 -- 
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 --
19
20
21
22 function get(get, config)
23         config.set("example.com", "test", "testkey", 123);
24         assert_equal(get("example.com", "test", "testkey"), 123, "Retrieving a set key");
25
26         config.set("*", "test", "testkey1", 321);
27         assert_equal(get("*", "test", "testkey1"), 321, "Retrieving a set global key");
28         assert_equal(get("example.com", "test", "testkey1"), 321, "Retrieving a set key of undefined host, of which only a globally set one exists");
29         
30         config.set("example.com", "test", ""); -- Creates example.com host in config
31         assert_equal(get("example.com", "test", "testkey1"), 321, "Retrieving a set key, of which only a globally set one exists");
32         
33         assert_equal(get(), nil, "No parameters to get()");
34         assert_equal(get("undefined host"), nil, "Getting for undefined host");
35         assert_equal(get("undefined host", "undefined section"), nil, "Getting for undefined host & section");
36         assert_equal(get("undefined host", "undefined section", "undefined key"), nil, "Getting for undefined host & section & key");
37
38         assert_equal(get("example.com", "undefined section", "testkey"), nil, "Defined host, undefined section");
39 end
40
41 function set(set, u)
42         assert_equal(set("*"), false, "Set with no section/key");
43         assert_equal(set("*", "set_test"), false, "Set with no key");   
44
45         assert_equal(set("*", "set_test", "testkey"), true, "Setting a nil global value");
46         assert_equal(set("*", "set_test", "testkey", 123), true, "Setting a global value");
47 end
48