testutil

package
v0.0.0-...-1db7b98 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package testutil provides utilities for testing.

Index

Constants

View Source
const FiberTestTimeoutMillis = 10000

FiberTestTimeoutMillis specifies the timeout for a test request to a Fiber HTTP server.

When tests are run with the race detector, the default 1-second timeout for a Fiber request may be exceeded.

Variables

This section is empty.

Functions

func NewUserRegistrationRequestMatcher

func NewUserRegistrationRequestMatcher(
	t *testing.T,
	want *user.RegistrationRequest,
	wantPassword string,
) func(*user.RegistrationRequest) bool

func NewUserUpdateRequestMatcher

func NewUserUpdateRequestMatcher(
	t *testing.T,
	want *user.UpdateRequest,
	wantPassword option.Option[string],
) func(*user.UpdateRequest) bool

Types

type FixedTimeSource

type FixedTimeSource struct {
	Time time.Time
}

FixedTimeSource returns a fixed time.

func (FixedTimeSource) Now

func (f FixedTimeSource) Now() time.Time

type MockUserService

type MockUserService struct {
	mock.Mock
}

func (*MockUserService) Authenticate

func (m *MockUserService) Authenticate(ctx context.Context, req *user.AuthRequest) (*user.User, error)

func (*MockUserService) GetUser

func (m *MockUserService) GetUser(ctx context.Context, id uuid.UUID) (*user.User, error)

func (*MockUserService) Register

func (*MockUserService) UpdateUser

func (m *MockUserService) UpdateUser(ctx context.Context, req *user.UpdateRequest) (*user.User, error)

type StdTimeSource

type StdTimeSource struct{}

StdTimeSource keeps time using the standard library.

func (StdTimeSource) Now

func (StdTimeSource) Now() time.Time

type TimeSource

type TimeSource interface {
	Now() time.Time
}

TimeSource provides the current time, allowing time to be mocked in tests.

Jump to

Keyboard shortcuts

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