assertions

package
v0.0.0-...-27b1c5b Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package assertions provides common assertion utilities for all testing modules

Package assertions provides common assertion utilities and types for all testing modules

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asserter

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

Asserter provides assertion capabilities for tests

func NewAsserter

func NewAsserter() *Asserter

NewAsserter creates a new asserter instance

func (*Asserter) Contains

func (a *Asserter) Contains(haystack, needle string, message string) bool

Contains asserts that a string contains a substring

func (*Asserter) Equal

func (a *Asserter) Equal(expected, actual interface{}, message string) bool

Equal asserts that two values are equal

func (*Asserter) False

func (a *Asserter) False(value bool, message string) bool

False asserts that a value is false

func (*Asserter) GetSteps

func (a *Asserter) GetSteps() []AssertionStep

GetSteps returns all assertion steps

func (*Asserter) Greater

func (a *Asserter) Greater(actual, expected interface{}, message string) bool

Greater asserts that a value is greater than another

func (*Asserter) HasFailures

func (a *Asserter) HasFailures() bool

HasFailures returns true if any assertions failed

func (*Asserter) Less

func (a *Asserter) Less(actual, expected interface{}, message string) bool

Less asserts that a value is less than another

func (*Asserter) Nil

func (a *Asserter) Nil(value interface{}, message string) bool

Nil asserts that a value is nil

func (*Asserter) NotContains

func (a *Asserter) NotContains(haystack, needle string, message string) bool

NotContains asserts that a string does not contain a substring

func (*Asserter) NotEqual

func (a *Asserter) NotEqual(expected, actual interface{}, message string) bool

NotEqual asserts that two values are not equal

func (*Asserter) NotNil

func (a *Asserter) NotNil(value interface{}, message string) bool

NotNil asserts that a value is not nil

func (*Asserter) Reset

func (a *Asserter) Reset()

Reset clears all assertion steps

func (*Asserter) True

func (a *Asserter) True(value bool, message string) bool

True asserts that a value is true

type AssertionStep

type AssertionStep struct {
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Status      TestStatus    `json:"status"`
	Error       error         `json:"error,omitempty"`
	Duration    time.Duration `json:"duration"`
	StartTime   time.Time     `json:"start_time"`
	EndTime     time.Time     `json:"end_time"`
	Expected    interface{}   `json:"expected,omitempty"`
	Actual      interface{}   `json:"actual,omitempty"`
}

AssertionStep represents a single assertion step in a test

type TestStatus

type TestStatus string

TestStatus represents the status of a test

const (
	TestStatusPassed  TestStatus = "passed"
	TestStatusFailed  TestStatus = "failed"
	TestStatusSkipped TestStatus = "skipped"
	TestStatusError   TestStatus = "error"
)

func (TestStatus) String

func (ts TestStatus) String() string

String returns the string representation of TestStatus

Jump to

Keyboard shortcuts

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