Documentation ¶
Overview ¶
Package is has a modified superset of the excellent github.com/matryer/is.
It adds new methods commonly needed in Bud, removes indentation and replaces displaying comments with optional messages that can be formatted.
Learn more in this discussion: https://github.com/livebud/bud/discussions/86
Index ¶
- type I
- func (is *I) Equal(a interface{}, b interface{}, args ...interface{})
- func (is *I) Fail(args ...interface{})
- func (is *I) Helper()
- func (is *I) In(list interface{}, item interface{}, args ...interface{})
- func (is *I) New(t T) *I
- func (is *I) NoErr(err error, args ...interface{})
- func (is *I) NotIn(list interface{}, item interface{}, args ...interface{})
- func (is *I) True(expr bool, args ...interface{})
- type T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type I ¶
type I struct {
// contains filtered or unexported fields
}
func (*I) Equal ¶
func (is *I) Equal(a interface{}, b interface{}, args ...interface{})
Equal asserts that a and b are equal.
func Test(t *testing.T) { is := is.New(t) a := greet("Mat") is.Equal(a, "Hi Mat") // greeting }
Will output:
your_test.go:123: Hey Mat != Hi Mat // greeting
func (*I) Fail ¶
func (is *I) Fail(args ...interface{})
Fail immediately fails the test.
func Test(t *testing.T) { is := is.New(t) is.Fail() // TODO: write this test }
func (*I) Helper ¶
func (is *I) Helper()
Helper marks the calling function as a test helper function. When printing file and line information, that function will be skipped.
Available with Go 1.7 and later.
func (*I) In ¶
func (is *I) In(list interface{}, item interface{}, args ...interface{})
In asserts that item is contained within list.
func (*I) New ¶
New is a method wrapper around the New function. It allows you to write subtests using a similar pattern:
func Test(t *testing.T) { is := is.New(t) t.Run("sub", func(t *testing.T) { is := is.New(t) // TODO: test }) }
func (*I) NoErr ¶
NoErr asserts that err is nil.
func Test(t *testing.T) { is := is.New(t) val, err := getVal() is.NoErr(err) // getVal error is.True(len(val) > 10) // val cannot be short }
Will output:
your_test.go:123: err: not found // getVal error
func (*I) NotIn ¶
func (is *I) NotIn(list interface{}, item interface{}, args ...interface{})
NotIn asserts that item is not contained within list