testing

package
v0.0.0-...-4decfc4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Assert = &Assertions{}

Assert provides assertion helpers for tests.

Functions

func AssertBound

func AssertBound(t *testing.T, app *coreFoundation.Application, key string)

AssertBound asserts that a key is bound in the container.

func AssertResolved

func AssertResolved(t *testing.T, app *coreFoundation.Application, key string) interface{}

AssertResolved asserts that a key can be resolved from the container.

func NewTestApp

func NewTestApp() *coreFoundation.Application

NewTestApp creates a new application instance for testing.

func RegisterAndBoot

func RegisterAndBoot(t *testing.T, app *coreFoundation.Application, provider foundation.ServiceProvider)

RegisterAndBoot registers and boots a provider, failing the test on error.

Types

type Assertions

type Assertions struct{}

Assertions provides test assertion methods.

func (*Assertions) Contains

func (a *Assertions) Contains(t *testing.T, haystack, needle string, msgAndArgs ...interface{})

Contains asserts that a string contains a substring.

func (*Assertions) Empty

func (a *Assertions) Empty(t *testing.T, collection interface{}, msgAndArgs ...interface{})

Empty asserts that a collection is empty.

func (*Assertions) Equal

func (a *Assertions) Equal(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{})

Equal asserts that two values are equal.

func (*Assertions) Error

func (a *Assertions) Error(t *testing.T, err error, msgAndArgs ...interface{})

Error asserts that an error is not nil.

func (*Assertions) ErrorContains

func (a *Assertions) ErrorContains(t *testing.T, err error, message string, msgAndArgs ...interface{})

ErrorContains asserts that an error contains a message.

func (*Assertions) False

func (a *Assertions) False(t *testing.T, condition bool, msgAndArgs ...interface{})

False asserts that a condition is false.

func (*Assertions) HasPrefix

func (a *Assertions) HasPrefix(t *testing.T, str, prefix string, msgAndArgs ...interface{})

HasPrefix asserts that a string has a prefix.

func (*Assertions) HasSuffix

func (a *Assertions) HasSuffix(t *testing.T, str, suffix string, msgAndArgs ...interface{})

HasSuffix asserts that a string has a suffix.

func (*Assertions) Len

func (a *Assertions) Len(t *testing.T, collection interface{}, length int, msgAndArgs ...interface{})

Len asserts that a collection has a specific length.

func (*Assertions) Nil

func (a *Assertions) Nil(t *testing.T, value interface{}, msgAndArgs ...interface{})

Nil asserts that a value is nil.

func (*Assertions) NoError

func (a *Assertions) NoError(t *testing.T, err error, msgAndArgs ...interface{})

NoError asserts that an error is nil.

func (*Assertions) NotContains

func (a *Assertions) NotContains(t *testing.T, haystack, needle string, msgAndArgs ...interface{})

NotContains asserts that a string does not contain a substring.

func (*Assertions) NotEmpty

func (a *Assertions) NotEmpty(t *testing.T, collection interface{}, msgAndArgs ...interface{})

NotEmpty asserts that a collection is not empty.

func (*Assertions) NotEqual

func (a *Assertions) NotEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{})

NotEqual asserts that two values are not equal.

func (*Assertions) NotNil

func (a *Assertions) NotNil(t *testing.T, value interface{}, msgAndArgs ...interface{})

NotNil asserts that a value is not nil.

func (*Assertions) True

func (a *Assertions) True(t *testing.T, condition bool, msgAndArgs ...interface{})

True asserts that a condition is true.

type LogEntry

type LogEntry struct {
	Level   string
	Message string
	Args    []interface{}
}

LogEntry represents a log entry.

type MockConfig

type MockConfig struct {
	// contains filtered or unexported fields
}

MockConfig is a mock configuration for testing.

func NewMockConfig

func NewMockConfig(values map[string]interface{}) *MockConfig

NewMockConfig creates a new mock config.

func (*MockConfig) Get

func (m *MockConfig) Get(key string) interface{}

Get retrieves a config value.

func (*MockConfig) Set

func (m *MockConfig) Set(key string, value interface{})

Set sets a config value.

type MockContainer

type MockContainer struct {
	// contains filtered or unexported fields
}

MockContainer is a simple mock container for testing.

func NewMockContainer

func NewMockContainer() *MockContainer

NewMockContainer creates a new mock container.

func (*MockContainer) Get

func (m *MockContainer) Get(key string) (interface{}, bool)

Get retrieves a binding from the mock container.

func (*MockContainer) Set

func (m *MockContainer) Set(key string, value interface{})

Set sets a binding in the mock container.

type MockLogger

type MockLogger struct {
	// contains filtered or unexported fields
}

MockLogger is a mock logger for testing.

func NewMockLogger

func NewMockLogger() *MockLogger

NewMockLogger creates a new mock logger.

func (*MockLogger) AssertLogged

func (m *MockLogger) AssertLogged(level, message string) bool

AssertLogged asserts that a message was logged at a specific level.

func (*MockLogger) AssertNotLogged

func (m *MockLogger) AssertNotLogged(level string) bool

AssertNotLogged asserts that a message was not logged at a specific level.

func (*MockLogger) Clear

func (m *MockLogger) Clear()

Clear clears all logged entries.

func (*MockLogger) Debug

func (m *MockLogger) Debug(msg string, args ...interface{})

Debug logs a debug message.

func (*MockLogger) DebugContext

func (m *MockLogger) DebugContext(ctx context.Context, msg string, args ...interface{})

DebugContext logs a debug message with context.

func (*MockLogger) Error

func (m *MockLogger) Error(msg string, args ...interface{})

Error logs an error message.

func (*MockLogger) ErrorContext

func (m *MockLogger) ErrorContext(ctx context.Context, msg string, args ...interface{})

ErrorContext logs an error message with context.

func (*MockLogger) GetLogs

func (m *MockLogger) GetLogs() []LogEntry

GetLogs returns all logged entries.

func (*MockLogger) Info

func (m *MockLogger) Info(msg string, args ...interface{})

Info logs an info message.

func (*MockLogger) InfoContext

func (m *MockLogger) InfoContext(ctx context.Context, msg string, args ...interface{})

InfoContext logs an info message with context.

func (*MockLogger) Warn

func (m *MockLogger) Warn(msg string, args ...interface{})

Warn logs a warning message.

func (*MockLogger) WarnContext

func (m *MockLogger) WarnContext(ctx context.Context, msg string, args ...interface{})

WarnContext logs a warning message with context.

func (*MockLogger) WithContext

func (m *MockLogger) WithContext(ctx context.Context) *logging.Logger

WithContext returns a logger with context.

func (*MockLogger) WithFields

func (m *MockLogger) WithFields(fields map[string]interface{}) *logging.Logger

WithFields returns a logger with fields.

Jump to

Keyboard shortcuts

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