Software /
code /
prosody
Annotate
tests/test_core_configmanager.lua @ 519:cccd610a0ef9
Insert copyright/license headers
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 03 Dec 2008 14:39:07 +0000 |
parent | 371:0dc5819660e8 |
child | 615:4ae3e81513f3 |
rev | line source |
---|---|
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
1 -- Prosody IM v0.1 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
2 -- Copyright (C) 2008 Matthew Wild |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
3 -- Copyright (C) 2008 Waqas Hussain |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
4 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
5 -- This program is free software; you can redistribute it and/or |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
6 -- modify it under the terms of the GNU General Public License |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
7 -- as published by the Free Software Foundation; either version 2 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
8 -- of the License, or (at your option) any later version. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
9 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
10 -- This program is distributed in the hope that it will be useful, |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
13 -- GNU General Public License for more details. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
14 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
15 -- You should have received a copy of the GNU General Public License |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
16 -- along with this program; if not, write to the Free Software |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
18 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
19 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
371
diff
changeset
|
20 |
371
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 function get(get, config) |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 config.set("example.com", "test", "testkey", 123); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 assert_equal(get("example.com", "test", "testkey"), 123, "Retrieving a set key"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 config.set("*", "test", "testkey1", 321); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 assert_equal(get("*", "test", "testkey1"), 321, "Retrieving a set global key"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 assert_equal(get("example.com", "test", "testkey1"), 321, "Retrieving a set key of undefined host, of which only a globally set one exists"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 config.set("example.com", "test", ""); -- Creates example.com host in config |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 assert_equal(get("example.com", "test", "testkey1"), 321, "Retrieving a set key, of which only a globally set one exists"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 assert_equal(get(), nil, "No parameters to get()"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 assert_equal(get("undefined host"), nil, "Getting for undefined host"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 assert_equal(get("undefined host", "undefined section"), nil, "Getting for undefined host & section"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 assert_equal(get("undefined host", "undefined section", "undefined key"), nil, "Getting for undefined host & section & key"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 assert_equal(get("example.com", "undefined section", "testkey"), nil, "Defined host, undefined section"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 end |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 function set(set, u) |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 assert_equal(set("*"), false, "Set with no section/key"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 assert_equal(set("*", "set_test"), false, "Set with no key"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 assert_equal(set("*", "set_test", "testkey"), true, "Setting a nil global value"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 assert_equal(set("*", "set_test", "testkey", 123), true, "Setting a global value"); |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 end |
0dc5819660e8
Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 |