Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertions for log files #171

Open
Tieske opened this issue Nov 22, 2020 · 1 comment
Open

assertions for log files #171

Tieske opened this issue Nov 22, 2020 · 1 comment

Comments

@Tieske
Copy link
Member

Tieske commented Nov 22, 2020

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

Issues:

  • applications don't always restart with clean logs in-between tests; so a start marker would be necessary
  • log file might not exist when start marker is called?
  • assertions for "contains"
  • needs filename where to look
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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants