Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/plugins/autoclothing.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
config.mode = 'fortress'
config.target = 'autoclothing'

function test.status()
local output = dfhack.run_command_silent('autoclothing')
expect.str_find('Automatic clothing management is currently', output)
expect.str_find('automatic clothing orders', output)
end

function test.wrong_arg_count_shows_usage()
local output, status = dfhack.run_command_silent('autoclothing', 'bogus')
expect.true_(output:find('Wrong number', 1, true) ~= nil
or status ~= 0)
end

function test.invalid_requirement_rejected()
local output, status = dfhack.run_command_silent('autoclothing',
'bogus', 'bogus')
expect.ne(0, status)
end
40 changes: 40 additions & 0 deletions test/plugins/autofarm.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
config.mode = 'fortress'
config.target = 'autofarm'

-- autofarm enabled state persists; leave it disabled
config.wrapper = function(test_fn)
return dfhack.with_finalize(function()
dfhack.run_command_silent('autofarm', 'disable')
end, test_fn)
end

function test.status()
local output = dfhack.run_command_silent('autofarm', 'status')
expect.ne('', output)
end

function test.enable_disable()
dfhack.run_command_silent('autofarm', 'enable')
local output = dfhack.run_command_silent('autofarm', 'status')
expect.str_find('Active', output)
dfhack.run_command_silent('autofarm', 'disable')
output = dfhack.run_command_silent('autofarm', 'status')
expect.str_find('Stopped', output)
end

function test.runonce()
local output, status = dfhack.run_command_silent('autofarm', 'runonce')
expect.eq(0, status)
end

function test.unknown_arg_shows_usage()
local output, status = dfhack.run_command_silent('autofarm', 'bogus')
expect.true_(output:find('autofarm', 1, true) ~= nil or status ~= 0)
end

function test.threshold_rejects_bad_plant()
local output, status = dfhack.run_command_silent('autofarm',
'threshold', '-1', '5')
expect.true_(output:find('Cannot find plant', 1, true) ~= nil
or status ~= 0)
end
21 changes: 21 additions & 0 deletions test/plugins/autogems.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
config.mode = 'fortress'
config.target = 'autogems'

-- autogems hooks should end removed
config.wrapper = function(test_fn)
return dfhack.with_finalize(function()
dfhack.run_command_silent('disable', 'autogems')
end, test_fn)
end

function test.reload_config()
local output, status = dfhack.run_command_silent('autogems-reload')
expect.ne('', output)
end

function test.enable_disable()
dfhack.run_command_silent('enable', 'autogems')
local output = dfhack.run_command_silent('autogems-reload')
dfhack.run_command_silent('disable', 'autogems')
expect.ne('', output)
end
47 changes: 47 additions & 0 deletions test/plugins/overlay.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
config.mode = 'fortress'
config.target = 'overlay'

local overlay = require('plugins.overlay')

-- overlay enable state persists via save_config; restore originals
local saved_enabled

config.wrapper = function(test_fn)
saved_enabled = {}
return dfhack.with_finalize(function()
for name, enabled in pairs(saved_enabled) do
dfhack.run_command_silent('overlay',
enabled and 'enable' or 'disable',
name)
end
end, test_fn)
end

local function save_widget_state(name)
local cfg = overlay.get_state().config[name]
saved_enabled[name] = cfg and cfg.enabled or false
end

-- overlay_command suppresses prints under run_command_silent (quiet
-- flag), so verify state changes directly instead of output
function test.list_succeeds()
local output, status = dfhack.run_command_silent('overlay', 'list')
expect.eq(0, status)
end

function test.enable_disable_widget()
overlay.rescan()
local db = overlay.get_state().db
local name = next(db)
expect.ne(nil, name)
save_widget_state(name)
dfhack.run_command_silent('overlay', 'disable', name)
expect.false_(overlay.get_state().config[name].enabled)
dfhack.run_command_silent('overlay', 'enable', name)
expect.true_(overlay.get_state().config[name].enabled)
end

function test.unknown_command_shows_usage()
local output, status = dfhack.run_command_silent('overlay', 'bogus')
expect.true_(output:find('overlay', 1, true) ~= nil or status ~= 0)
end
Loading