Documentation
¶
Index ¶
- func Assert(ctx context.Context, truth bool, msg string, opts ...Option)
- func AssertWithTimeout(ctx context.Context, timeout time.Duration, truth bool, msg string, ...)
- func Contains(ctx context.Context, str, substr string, msg string, opts ...Option)
- func Equal(ctx context.Context, expected, actual any, msg string, opts ...Option)
- func False(ctx context.Context, value bool, msg string, opts ...Option)
- func Never(ctx context.Context, msg string, opts ...Option)
- func Nil(ctx context.Context, item any, msg string, opts ...Option)
- func NoError(ctx context.Context, err error, msg string, opts ...Option)
- func NotContains(ctx context.Context, str, substr string, msg string, opts ...Option)
- func NotEmpty(ctx context.Context, str string, msg string, opts ...Option)
- func NotEqual(ctx context.Context, expected, actual any, msg string, opts ...Option)
- func NotNil(ctx context.Context, item any, msg string, opts ...Option)
- func ProcessDeferredAssertions(ctx context.Context, opts ...Option)
- func True(ctx context.Context, value bool, msg string, opts ...Option)
- type AssertConfig
- type AssertData
- type AssertFlush
- type AssertHandler
- func (a *AssertHandler) AddAssertData(key string, value AssertData)
- func (a *AssertHandler) AddAssertFlush(flusher AssertFlush)
- func (a *AssertHandler) Assert(ctx context.Context, truth bool, msg string, data ...any)
- func (a *AssertHandler) AssertWithTimeout(ctx context.Context, timeout time.Duration, truth bool, msg string, ...)
- func (a *AssertHandler) Never(ctx context.Context, msg string, data ...any)
- func (a *AssertHandler) Nil(ctx context.Context, item any, msg string, data ...any)
- func (a *AssertHandler) NoError(ctx context.Context, err error, msg string, data ...any)
- func (a *AssertHandler) NotNil(ctx context.Context, item any, msg string, data ...any)
- func (a *AssertHandler) ProcessDeferredAssertions(ctx context.Context)
- func (a *AssertHandler) RemoveAssertData(key string)
- func (a *AssertHandler) SetDebugMode(debugMode bool)
- func (a *AssertHandler) SetDeferAssertions(deferMode bool)
- func (a *AssertHandler) SetExitFunc(exitFunc func(int))
- func (a *AssertHandler) SetFormatter(formatter Formatter)
- func (a *AssertHandler) SetVerboseMode(verboseMode bool)
- func (a *AssertHandler) ToWriter(w io.Writer)
- type Formatter
- type JSONFormatter
- type Option
- func WithCrashOnFailure() Option
- func WithDebugMode() Option
- func WithDeferMode(deferMode bool) Option
- func WithExitFunc(f func(int)) Option
- func WithFormatter(f Formatter) Option
- func WithLogLevel(level string) Option
- func WithPanicOnFailure() Option
- func WithProductionDefaults() Option
- func WithQuietMode() Option
- func WithSilentMode() Option
- func WithTestingDefaults() Option
- func WithVerboseMode() Option
- func WithWriter(w io.Writer) Option
- type TextFormatter
- type YAMLFormatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertWithTimeout ¶ added in v1.3.0
func AssertWithTimeout(ctx context.Context, timeout time.Duration, truth bool, msg string, opts ...Option)
AssertWithTimeout checks if the condition is true with a timeout, failing if false
func Contains ¶ added in v1.3.0
Contains checks if a string contains a substring, failing if it doesn't
func NotContains ¶ added in v1.3.0
NotContains checks if a string does not contain a substring, failing if it does
func NotEqual ¶ added in v1.3.0
NotEqual checks if two values are not equal, failing if they are equal
func ProcessDeferredAssertions ¶ added in v1.3.0
ProcessDeferredAssertions processes any deferred assertions on the default handler
Types ¶
type AssertConfig ¶ added in v1.3.0
type AssertConfig struct {
// contains filtered or unexported fields
}
AssertConfig holds temporary configuration for assert operations
type AssertData ¶
type AssertData interface {
Dump() string
}
Define interfaces for logging/asserting
type AssertFlush ¶
type AssertFlush interface {
Flush()
}
type AssertHandler ¶
type AssertHandler struct {
// contains filtered or unexported fields
}
Define the AssertHandler to encapsulate state
func (*AssertHandler) AddAssertData ¶
func (a *AssertHandler) AddAssertData(key string, value AssertData)
func (*AssertHandler) AddAssertFlush ¶
func (a *AssertHandler) AddAssertFlush(flusher AssertFlush)
func (*AssertHandler) AssertWithTimeout ¶
func (*AssertHandler) Never ¶
func (a *AssertHandler) Never(ctx context.Context, msg string, data ...any)
func (*AssertHandler) ProcessDeferredAssertions ¶
func (a *AssertHandler) ProcessDeferredAssertions(ctx context.Context)
Process all deferred assertions at once, logging or exiting if needed
func (*AssertHandler) RemoveAssertData ¶
func (a *AssertHandler) RemoveAssertData(key string)
func (*AssertHandler) SetDebugMode ¶ added in v1.3.1
func (a *AssertHandler) SetDebugMode(debugMode bool)
func (*AssertHandler) SetDeferAssertions ¶
func (a *AssertHandler) SetDeferAssertions(deferMode bool)
SetDeferAssertions allows toggling deferred assertion mode
func (*AssertHandler) SetExitFunc ¶
func (a *AssertHandler) SetExitFunc(exitFunc func(int))
func (*AssertHandler) SetFormatter ¶
func (a *AssertHandler) SetFormatter(formatter Formatter)
func (*AssertHandler) SetVerboseMode ¶ added in v1.3.1
func (a *AssertHandler) SetVerboseMode(verboseMode bool)
func (*AssertHandler) ToWriter ¶
func (a *AssertHandler) ToWriter(w io.Writer)
type Option ¶ added in v1.3.0
type Option func(*AssertConfig)
Option defines a function that can modify assert configuration
func WithCrashOnFailure ¶ added in v1.3.0
func WithCrashOnFailure() Option
Additional convenience options for common use cases
func WithDebugMode ¶ added in v1.3.1
func WithDebugMode() Option
func WithDeferMode ¶ added in v1.3.0
func WithExitFunc ¶ added in v1.3.0
func WithFormatter ¶ added in v1.3.0
Option functions for configuring assert behavior
func WithLogLevel ¶ added in v1.3.0
func WithPanicOnFailure ¶ added in v1.3.0
func WithPanicOnFailure() Option
func WithProductionDefaults ¶ added in v1.3.0
func WithProductionDefaults() Option
func WithQuietMode ¶ added in v1.3.1
func WithQuietMode() Option
func WithSilentMode ¶ added in v1.3.0
func WithSilentMode() Option
func WithTestingDefaults ¶ added in v1.3.0
func WithTestingDefaults() Option
Combine multiple options into one
func WithVerboseMode ¶ added in v1.3.1
func WithVerboseMode() Option
func WithWriter ¶ added in v1.3.0
type TextFormatter ¶
type TextFormatter struct{}
TextFormatter is the default plain text output format