Skip to content

Commit

Permalink
Add test that removeJob() actually removes jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
lethosor committed Aug 31, 2023
1 parent 40bfb6b commit bb79755
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/modules/job.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
config.target = 'core'
config.mode = 'title' -- alters world state, not safe when a world is loaded

function test.removeJob()
-- removeJob() calls DF code, so ensure that that DF code is actually running

-- for an explanation of why this is necessary to check,
-- see https://github.com/DFHack/dfhack/pull/3713 and Job.cpp:removeJob()

expect.nil_(df.global.world.jobs.list.next, 'job list is not empty')

local job = df.job:new() -- will be deleted by removeJob() if the test passes
dfhack.job.linkIntoWorld(job)
expect.true_(df.global.world.jobs.list.next, 'job list is empty')
expect.eq(df.global.world.jobs.list.next.item, job, 'expected job not found in list')

expect.true_(dfhack.job.removeJob(job))
expect.nil_(df.global.world.jobs.list.next, 'job list is not empty after removeJob()')
end

0 comments on commit bb79755

Please sign in to comment.