lunarmodules / luassert

Assertion library for Lua
MIT License
202 stars 76 forks source link

assertions for log files #171

Open Tieske opened 3 years ago

Tieske commented 3 years ago

Quite common we need to validate behaviour by checking log files. Some helper assertions would be nice.

Issues:

local logfile = require "luassert.logfile"

it("checks a log file", function()
    local log = logfile("./logs/error.log")   -- sets a start marker (file size?), should not fail if file doesn't exist

    -- do stuff 

    assert.logfile(log).exists()
    assert.logfile(log).contains("some Lua pattern", [occurrences])
end)
DorianGray commented 3 years ago

not a bad idea! how about just "file" though?