Tests for overload and important internal data

This commit is contained in:
SX 2021-11-12 19:27:50 +02:00
parent 8095dd9fc0
commit 5aeeb273ca
2 changed files with 48 additions and 0 deletions

View File

@ -260,3 +260,28 @@ describe("Technic API", function()
end)
end)
describe("Technic API internals", function()
it("technic.machines contain only machines", function()
local types = {PR=1, RE=1, PR_RE=1, BA=1}
for tier, machines in pairs(technic.machines) do
assert.is_hashed(machines)
for nodename, machine_type in pairs(machines) do
assert.is_hashed(minetest.registered_nodes[nodename])
local groups = minetest.registered_nodes[nodename].groups
local tier_group
for group,_ in pairs(groups) do
assert.is_nil(group:find("technic_.*_cable$"), "Cable in machines table: "..tostring(nodename))
end
assert.not_nil(groups.technic_machine, "Missing technic_machine group for "..tostring(machine_type))
assert.not_nil(types[machine_type], "Missing type for "..tostring(machine_type))
end
end
end)
it("technic.cables TBD, misleading name and should be updated", function()
pending("TBD technic.cables naming and need, see technic networks data for possible options")
end)
end)

View File

@ -151,6 +151,29 @@ describe("Power network helper", function()
end)
describe("Network initialization", function()
describe("overload", function()
world.layout({
{{x=10,y=11,z=10}, "technic:switching_station"}, -- First network
{{x=10,y=10,z=10}, "technic:hv_cable"},
{{x=11,y=10,z=10}, "technic:hv_generator"}, -- This machine is connected to both networks
{{x=12,y=10,z=10}, "technic:hv_cable"},
{{x=12,y=11,z=10}, "technic:switching_station"}, -- Second network
})
it("networks connected through machine", function()
local net1 = get_network_fixture({x=10,y=11,z=10})
local net2 = get_network_fixture({x=12,y=11,z=10})
assert.truthy(technic.is_overloaded(net1.id))
assert.truthy(technic.is_overloaded(net2.id))
end)
end)
end)
describe("technic.merge_networks", function()
describe("function behavior", function()