mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
test: added tests for runner
This commit is contained in:
parent
ab1b512545
commit
352dbadcb6
2 changed files with 147 additions and 0 deletions
40
tests/manage/runner_spec.lua
Normal file
40
tests/manage/runner_spec.lua
Normal file
|
@ -0,0 +1,40 @@
|
|||
local Runner = require("lazy.manage.runner")
|
||||
|
||||
describe("runner", function()
|
||||
local plugins = { { name = "plugin1" }, { name = "plugin2" } }
|
||||
|
||||
---@type {plugin:string, task:string}[]
|
||||
local runs = {}
|
||||
before_each(function()
|
||||
runs = {}
|
||||
end)
|
||||
|
||||
package.loaded["lazy.manage.task.test"] = {}
|
||||
for i = 1, 10 do
|
||||
package.loaded["lazy.manage.task.test"]["test" .. i] = {
|
||||
---@param task LazyTask
|
||||
run = function(task)
|
||||
table.insert(runs, { plugin = task.plugin.name, task = task.type })
|
||||
end,
|
||||
}
|
||||
package.loaded["lazy.manage.task.test"]["error" .. i] = {
|
||||
---@param task LazyTask
|
||||
run = function(task)
|
||||
table.insert(runs, { plugin = task.plugin.name, task = task.type })
|
||||
error("error" .. i)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
it("runs the pipeline", function()
|
||||
local runner = Runner.new({ plugins = plugins, pipeline = { "test.test1", "test.test2" } })
|
||||
runner:start()
|
||||
assert.equal(4, #runs)
|
||||
end)
|
||||
|
||||
it("aborts on error", function()
|
||||
local runner = Runner.new({ plugins = plugins, pipeline = { "test.test1", "test.error1", "test.test2" } })
|
||||
runner:start()
|
||||
assert.equal(4, #runs)
|
||||
end)
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue