test

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPanic

func CheckPanic(t *testing.T, fn func(), contains string) bool

CheckPanic checks that fn() panics and that the panic() arg is a string that contains contains.

func EqualBool

func EqualBool(t *testing.T, got, expected bool, args ...any) bool

EqualBool checks that got equals expected.

func EqualErrorMessage

func EqualErrorMessage(t *testing.T, got, expected any,
	args ...any)

EqualErrorMessage prints a test error message of the form:

Message
Failed test
       got: got_value
  expected: expected_value

func EqualInt

func EqualInt(t *testing.T, got, expected int, args ...any) bool

EqualInt checks that got equals expected.

func EqualStr

func EqualStr(t *testing.T, got, expected string, args ...any) bool

EqualStr checks that got equals expected.

func Error added in v1.8.0

func Error(t *testing.T, err error, args ...any) bool

Error checks that err is non-nil.

func IsFalse

func IsFalse(t *testing.T, got bool, args ...any) bool

IsFalse checks that got is false.

func IsTrue

func IsTrue(t *testing.T, got bool, args ...any) bool

IsTrue checks that got is true.

func NoError added in v1.8.0

func NoError(t *testing.T, err error, args ...any) bool

NoError checks that err is nil.

Types

type ParallelTestingTB added in v1.10.0

type ParallelTestingTB struct {
	IsParallel bool
	*TestingTB
}

ParallelTestingTB is a type implementing testing.TB and a Parallel() method intended to be used in tests.

func NewParallelTestingTB added in v1.10.0

func NewParallelTestingTB(name string) *ParallelTestingTB

NewParallelTestingTB returns a new instance of *ParallelTestingTB.

func (*ParallelTestingTB) Parallel added in v1.10.0

func (t *ParallelTestingTB) Parallel()

Parallel mocks the testing.T.Parallel method. Not thread-safe.

type TestingT

type TestingT struct {
	Messages  []string
	IsFatal   bool
	HasFailed bool
}

TestingT is a type implementing td.TestingT intended to be used in tests.

func NewTestingT added in v1.2.0

func NewTestingT() *TestingT

NewTestingT returns a new instance of *TestingT.

func (*TestingT) CatchFatal added in v1.10.0

func (t *TestingT) CatchFatal(fn func()) (fatalStr string)

func (*TestingT) ContainsMessages added in v1.12.0

func (t *TestingT) ContainsMessages(expectedMsgs ...string) []string

ContainsMessages checks expectedMsgs are all present in Messages, in this order. It stops when a message is not found and returns the remaining messages.

func (*TestingT) Error

func (t *TestingT) Error(args ...any)

Error mocks testing.T Error method.

func (*TestingT) Fatal

func (t *TestingT) Fatal(args ...any)

Fatal mocks testing.T.Fatal method.

func (*TestingT) Helper

func (t *TestingT) Helper()

Helper mocks testing.T.Helper method.

func (*TestingT) LastMessage

func (t *TestingT) LastMessage() string

LastMessage returns the last message.

func (*TestingT) ResetMessages added in v1.9.0

func (t *TestingT) ResetMessages()

ResetMessages resets the messages.

type TestingTB added in v1.6.0

type TestingTB struct {
	TestingT

	testing.TB
	// contains filtered or unexported fields
}

TestingTB is a type implementing testing.TB intended to be used in tests.

func NewTestingTB added in v1.6.0

func NewTestingTB(name string) *TestingTB

NewTestingTB returns a new instance of *TestingTB.

func (*TestingTB) Cleanup added in v1.6.0

func (t *TestingTB) Cleanup(fn func())

Cleanup mocks testing.T.Cleanup method. Not thread-safe but we don't care in tests.

func (*TestingTB) Error added in v1.6.0

func (t *TestingTB) Error(args ...any)

Fatal mocks testing.T.Error method.

func (*TestingTB) Errorf added in v1.6.0

func (t *TestingTB) Errorf(format string, args ...any)

Errorf mocks testing.T.Errorf method.

func (*TestingTB) Fail added in v1.6.0

func (t *TestingTB) Fail()

Fail mocks testing.T.Fail method.

func (*TestingTB) FailNow added in v1.6.0

func (t *TestingTB) FailNow()

FailNow mocks testing.T.FailNow method.

func (*TestingTB) Failed added in v1.6.0

func (t *TestingTB) Failed() bool

Failed mocks testing.T.Failed method.

func (*TestingTB) Fatal added in v1.6.0

func (t *TestingTB) Fatal(args ...any)

Fatal mocks testing.T.Fatal method.

func (*TestingTB) Fatalf added in v1.6.0

func (t *TestingTB) Fatalf(format string, args ...any)

Fatalf mocks testing.T.Fatalf method.

func (*TestingTB) Helper added in v1.6.0

func (t *TestingTB) Helper()

Helper mocks testing.T.Helper method.

func (*TestingTB) Log added in v1.6.0

func (t *TestingTB) Log(args ...any)

Log mocks testing.T.Log method.

func (*TestingTB) Logf added in v1.6.0

func (t *TestingTB) Logf(format string, args ...any)

Logf mocks testing.T.Logf method.

func (*TestingTB) Name added in v1.6.0

func (t *TestingTB) Name() string

Name mocks testing.T.Name method.

func (*TestingTB) Skip added in v1.6.0

func (t *TestingTB) Skip(args ...any)

Skip mocks testing.T.Skip method.

func (*TestingTB) SkipNow added in v1.6.0

func (t *TestingTB) SkipNow()

SkipNow mocks testing.T.SkipNow method.

func (*TestingTB) Skipf added in v1.6.0

func (t *TestingTB) Skipf(format string, args ...any)

Skipf mocks testing.T.Skipf method.

func (*TestingTB) Skipped added in v1.6.0

func (t *TestingTB) Skipped() bool

Skipped mocks testing.T.Skipped method.

Jump to

Keyboard shortcuts

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