testlogrus

module
v0.0.0-...-6801039 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2024 License: MIT

README

testlogrus

How to use ?

go get -u github.com/kilianpaquier/testlogrus@latest

Features

The testlogrus package exposes two functions to use during testing. When calling Logs function, the logs are reset, as such if multiple verification are to be done, you should first affect Logs result to a variable.

func TestSome(t *testing.T) {
    t.Run("error_test", func(t *testing.T) {
        // Arrange
        // mandatory call to setup logrus logging hook
        // logging hook is set to nil at the end of t.Run
        testlogrus.CatchLogs(t)

        // Act
        // call some functions that log with logrus

        // Assert
        logs := testlogrus.Logs()
        // assert some things around function expected logs
    })
}

Directories

Path Synopsis
The testlogrus package exposes two functions to use during testing.
The testlogrus package exposes two functions to use during testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL