# README
testutil
Utility helpers for testing, based on go-cmp
Install
go get github.com/avakarev/go-util/testutil
Usage
package hello_test
import (
"fmt"
"testing"
"github.com/avakarev/go-util/testutil"
)
func Hello() (string, error) {
return "Hello World", nil
}
func TestHello(t *testing.T) {
s, err := Hello()
testutil.MustNoErr(err, t)
testutil.Diff("Hello World", s, t)
}
License
go-testutil
is licensed under MIT license. (see LICENSE)
# Functions
Diff fails the test if `want` differs from `got`, and prints human-readable error.
FixtureBytes returns content bytes of the given fixture.
FixturePath returns absolute path to the given fixture.
FixtureReader returns io reader of the given fixture.
MustErr fails the test if `want` error differs from `got` error.
MustNoErr fail the test if `err` is not nil.
SetEnv set given Env value entries to the process's environment and returns reset function.
# Type aliases
Env is a helper type to declare map of environment variables key/value pairs.