mirror of
https://github.com/vxcontrol/soldr-modules.git
synced 2026-07-19 13:33:58 -04:00
27 lines
694 B
Lua
27 lines
694 B
Lua
package.path = package.path .. ";cmodule/?.lua"
|
|
local exec = require "exec"
|
|
|
|
local function string_contains(str, sub)
|
|
return string.find(str, sub, 1, true) ~= nil
|
|
end
|
|
|
|
describe("exec", function()
|
|
it("runs a given command", function()
|
|
assert(exec("true"))
|
|
end)
|
|
|
|
it("must fail unless the exit code is 0", function()
|
|
local ok, err = exec("echo ERROR; false")
|
|
assert(not ok)
|
|
assert(string_contains(err, 'exit=1: ERROR'),
|
|
string.format("unexpected error message: %s", err))
|
|
end)
|
|
|
|
test("a bad command", function()
|
|
local ok, err = exec("unknown-command")
|
|
assert(not ok)
|
|
assert(string_contains(err, "not found"),
|
|
string.format("unexpected error message: %s", err))
|
|
end)
|
|
end)
|