-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a74d41
commit c157468
Showing
5 changed files
with
78 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
set -e | ||
cd tests/ | ||
lua test_basic_functions.lua -v | ||
lua test_utils.lua -v | ||
lua test_netjson_monitoring.lua -v |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package.path = package.path .. ";../?.lua" | ||
|
||
local luaunit = require('luaunit') | ||
|
||
local utils = require('../utils') | ||
|
||
function testSplitFunction() | ||
-- When pattern is present | ||
luaunit.assertEquals(utils.split("OpenWISP","n"), {"Ope", "WISP"}) | ||
luaunit.assertEquals(utils.split("OpenWISP","WISP"), {"Open"}) | ||
|
||
-- When pattern is not available | ||
luaunit.assertEquals(utils.split("OpenWISP","a"), {"OpenWISP"}) | ||
end | ||
|
||
function testHasValue() | ||
-- When value is present | ||
luaunit.assertEquals(utils.has_value({2,4,5},4), true) | ||
luaunit.assertEquals(utils.has_value({1,2,3,7,9},9), true) | ||
|
||
-- When value is not present | ||
luaunit.assertEquals(utils.has_value({2,4,5},3), false) | ||
luaunit.assertEquals(utils.has_value({1,2,3,7,9},8), false) | ||
|
||
end | ||
|
||
function testStartsWith() | ||
-- When string starts with the substring given | ||
luaunit.assertEquals(utils.starts_with("OpenWISP", "Open"), true) | ||
luaunit.assertEquals(utils.starts_with("NetJSon", "Net"), true) | ||
|
||
-- when string doesn't starts with the substring given | ||
luaunit.assertEquals(utils.starts_with("OpenWISP", "Ov"), false) | ||
end | ||
|
||
function testTableEmpty() | ||
-- When table is empty | ||
luaunit.assertEquals(utils.is_table_empty(nil), true) | ||
luaunit.assertEquals(utils.is_table_empty({}), true) | ||
|
||
-- When table is not empty | ||
luaunit.assertEquals(utils.is_table_empty({1,2,3,4}), false) | ||
luaunit.assertEquals(utils.is_table_empty({"wireless", "wired", "system"}), false) | ||
end | ||
|
||
function testArrayConcat() | ||
luaunit.assertEquals(utils.array_concat({4,5,6},{1,2,3}), {1, 2, 3, 4, 5, 6}) | ||
luaunit.assertEquals(utils.array_concat({"wireless"},{"wired"}), {"wired", "wireless"}) | ||
luaunit.assertEquals(utils.array_concat({"system", "network"},{"firewall"}), {"firewall", "system", "network"}) | ||
end | ||
|
||
function testDictMerge() | ||
luaunit.assertEquals(utils.dict_merge({['1']='OpenWISP'},{['3']='NetJSon'}), {["1"]="OpenWISP", ["3"]="NetJSon"}) | ||
luaunit.assertEquals(utils.dict_merge({['1']='OpenWISP'},{['1']='NetJSon'}), {["1"]="OpenWISP"}) | ||
end | ||
|
||
os.exit(luaunit.LuaUnit.run()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters