Skip to content

Commit

Permalink
Test node placement for all listed nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
S-S-X committed Oct 24, 2021
1 parent 76e3bca commit 225e41c
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
6 changes: 4 additions & 2 deletions technic/spec/fixtures/pipeworks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ _G.pipeworks = {}
_G.pipeworks.button_label = ""
_G.pipeworks.fs_helpers = {}
_G.pipeworks.fs_helpers.cycling_button = function(...) return "" end
_G.pipeworks.scan_for_tube_objects = function(...) end
_G.pipeworks.tube_inject_item = function(...) end
_G.pipeworks = setmetatable(_G.pipeworks, {
__call = function(self,...) return self end,
__index = function(...) return function(...)end end,
})
65 changes: 65 additions & 0 deletions technic/spec/nodes_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
require("mineunit")
--[[
Technic network unit tests.
Execute busted at technic source directory.
--]]

-- Load fixtures required by tests
mineunit("core")
mineunit("player")
mineunit("protection")
mineunit("common/after")
mineunit("server")
mineunit("voxelmanip")

fixture("pipeworks")
fixture("network")
fixture("default")
fixture("technic_worldgen")
fixture("mesecons")

sourcefile("init")

describe("Technic node placement", function()

local function placement_test(player, name, xpos)
return function()
player:get_inventory():set_stack("main", 1, name)
player:do_place({x=xpos, y=1, z=0})
end
end

local player = Player("SX")

-- Execute on mods loaded callbacks to finish loading.
mineunit:mods_loaded()
-- Tell mods that 1 minute passed already to execute all weird minetest.after hacks.
mineunit:execute_globalstep(60)

local nodes = {}
for nodename, def in pairs(minetest.registered_nodes) do
if not (def.groups and def.groups.not_in_creative_inventory) and nodename:find("^technic:") then
table.insert(nodes, nodename)
end
end

setup(function()
world.clear()
mineunit:execute_on_joinplayer(player)
end)

teardown(function()
mineunit:execute_on_leaveplayer(player)
end)

for x, nodename in ipairs(nodes) do
it("player can place "..nodename, placement_test(player, nodename, x))
end

it("gloabalstep works", function()
for _=1,60 do
mineunit:execute_globalstep(1)
end
end)

end)

0 comments on commit 225e41c

Please sign in to comment.