server/scripts/tests/faction.lua

32 lines
683 B
Lua
Raw Permalink Normal View History

require "lunit"
module ('tests.eressea.faction', package.seeall, lunit.testcase)
local f
function setup()
conf = [[{
"races": {
"human" : {}
}
}]]
eressea.config.reset()
assert(eressea.config.parse(conf)==0)
f = faction.create("human", "faction@eressea.de", "de")
2015-03-07 13:56:31 +01:00
assert(f~=nil)
end
function test_faction_flags()
2017-01-22 18:51:20 +01:00
assert_equal(6, f.flags) -- FFL_ISNEW|FFL_PWMSG
2015-02-20 20:35:02 +01:00
f.flags = 42
assert_equal(42, f.flags)
end
function test_get_faction()
2015-02-20 20:35:02 +01:00
assert_equal(f, get_faction(f.id))
assert_equal(f, faction.get(f.id))
local nf = f.id
if nf>1 then nf = nf - 1 else nf = 1 end
assert_equal(nil, faction.get(nf))
end