diff --git a/test/plugins/autoclothing.lua b/test/plugins/autoclothing.lua new file mode 100644 index 0000000000..8d02af8789 --- /dev/null +++ b/test/plugins/autoclothing.lua @@ -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 diff --git a/test/plugins/autofarm.lua b/test/plugins/autofarm.lua new file mode 100644 index 0000000000..0573d7379d --- /dev/null +++ b/test/plugins/autofarm.lua @@ -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 diff --git a/test/plugins/autogems.lua b/test/plugins/autogems.lua new file mode 100644 index 0000000000..3dcb905960 --- /dev/null +++ b/test/plugins/autogems.lua @@ -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 diff --git a/test/plugins/overlay.lua b/test/plugins/overlay.lua new file mode 100644 index 0000000000..0f7e5d1a48 --- /dev/null +++ b/test/plugins/overlay.lua @@ -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