testkit

package
v0.0.0-...-d6d061b Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const TimeEqualityTolerance = 60 * time.Second

Variables

This section is empty.

Functions

func CreateTestLogger

func CreateTestLogger() (*bytes.Buffer, *bytes.Buffer, logging.Logger)

func GenerateFakeEmail

func GenerateFakeEmail() string

GenerateFakeEmail generates a randomized email addresss.

func GenerateFakePassword

func GenerateFakePassword() string

GenerateFakeEmail generates a randomized password.

func MustGenerateRandomString

func MustGenerateRandomString(
	length int,
	allowLowerAlpha bool,
	allowUpperAlpha bool,
	allowNumeric bool,
) string

MustGenerateRandomString generates a random string and panics on error.

func MustParseLogMessage

func MustParseLogMessage(msg string) (string, time.Time, string, string)

func MustParseMailMessage

func MustParseMailMessage(msg string) (string, string)

func RequireTimeAlmostEqual

func RequireTimeAlmostEqual(t TestingT, expected time.Time, actual time.Time)

RequireTimeAlmostEqual requires that expected and actual times are within at most a certain duration tolerance of each other.

Types

type MockTestingT

type MockTestingT struct {
	Cleanups   []func()
	HasFailed  bool
	HasSkipped bool
	Logs       []string
}

MockTestingT implements TestingT and is a mock implementation of testing.T.

func NewMockTestingT

func NewMockTestingT() *MockTestingT

NewMockTestingT creates a new MockTestingT.

func (*MockTestingT) Cleanup

func (t *MockTestingT) Cleanup(f func())

Cleanup stores a cleanup function.

func (*MockTestingT) Error

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

Error is equivalent to Log followed by Fail.

func (*MockTestingT) Errorf

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

Errorf is equivalent to Logf followed by Fail.

func (*MockTestingT) Fail

func (t *MockTestingT) Fail()

Fail is equivalent to FailNow.

func (*MockTestingT) FailNow

func (t *MockTestingT) FailNow()

FailNow records the test as failed.

func (*MockTestingT) Failed

func (t *MockTestingT) Failed() bool

Failed reports whether the test has failed.

func (*MockTestingT) Fatal

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

Fatal is equivalent to Log followed by FailNow.

func (*MockTestingT) Fatalf

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

Fatalf is equivalent to Logf followed by FailNow.

func (*MockTestingT) Log

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

Log records a log entry.

func (*MockTestingT) Logf

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

Logf records a formatted log entry.

func (*MockTestingT) Skip

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

Skip is equivalent to Log followed by SkipNow.

func (*MockTestingT) SkipNow

func (t *MockTestingT) SkipNow()

SkipNow records the test to be skipped.

func (*MockTestingT) Skipf

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

Skipf is equivalent to Logf followed by SkipNow.

func (*MockTestingT) Skipped

func (t *MockTestingT) Skipped() bool

Skipped reports whether the test was skipped.

type TestingT

type TestingT interface {
	Cleanup(f func())
	Error(args ...any)
	Errorf(format string, args ...any)
	Fail()
	FailNow()
	Failed() bool
	Fatal(args ...any)
	Fatalf(format string, args ...any)
	Log(args ...any)
	Logf(format string, args ...any)
	Skip(args ...any)
	SkipNow()
	Skipf(format string, args ...any)
	Skipped() bool
}

TestingT is an interface wrapper around *testing.T.

Jump to

Keyboard shortcuts

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