Categorygithub.com/gregoryv/asserter
modulepackage
0.5.0
Repository: https://github.com/gregoryv/asserter.git
Documentation: pkg.go.dev

# README

Build Status codecov Maintainability

asserter - Package for oneline assertions

NO LONGER MAINTAINED!!!

After some consideration and reading Assert Libraries I've decided to stop using this package and advise you the same.

Quick start

go get github.com/gregoryv/asserter

In your tests

func Test_something(t *testing.T) {
    got, err := something()

    assert := asserter.New(t)
    assert(err == nil).Fatal(err)
    assert(got == exp).Errorf("%v, expected %v", got, exp)
    // same as
    assert().Equals(got, exp)

    assert().Contains(got, "text")
    assert().Contains(got, 1)

    // Check readers content
    resp, err := http.Get("http://example.com")
    assert(err == nil).Fatal(err)
    assert().Contains(resp.Body, "<title>")
}

HTTP handler specific

assert := asserter.New(t)
exp := assert().ResponseFrom(handler)
// io.Reader option means body
exp.StatusCode(200, "POST", "/", strings.NewReader("the body"))
// string option means error message
exp.StatusCode(200, "GET", "/", "should be ok")
// http.Header additional headers
exp.StatusCode(200, "GET", "/", http.Header{
    "Content-Type": []string{"text/plain"},
})

# Functions

New returns a WrappedT.Assert func for online assertions.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
Testar combines testing.T with and Asserter.

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author