assert

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 9 Imported by: 15

Documentation

Index

Constants

View Source
const ColumnUnknown = 0

ColumnUnknown is used when the column associated with a LocationInfo is not available

Variables

This section is empty.

Functions

func AlwaysTrue

func AlwaysTrue(text string, cond bool, values any, options ...string)

AlwaysTrue asserts that when this is evaluated the condition will always be true, and that this is evaluated at least once. Could be named name is Always()

func AlwaysTrueIfOccurs

func AlwaysTrueIfOccurs(text string, cond bool, values any, options ...string)

AlwaysTrueIfOccurs asserts that when this is evaluated the condition will always be true, or that this is never evaluated. Could be named is UnreachableOrAlways()

func AssertImpl

func AssertImpl(text string, cond bool, values any, loc *LocationInfo, hit bool, must_hit bool, expecting bool, expect_type string, options ...string)

func NeverOccurs

func NeverOccurs(text string, values any, options ...string)

NeverOccurs asserts that this is never evaluated. This assertion will fail if it is evaluated. Could be named is Unreachable()

func SometimesOccurs

func SometimesOccurs(text string, values any, options ...string)

SometimesOccurs asserts that this is evaluated at least once. This assertion will fail if it is not evaluated, and otherwise will pass. Could be named is Reachable()

func SometimesTrue

func SometimesTrue(text string, cond bool, values any, options ...string)

SometimesTrue asserts that when this is evaluated the condition will sometimes be true, and that this is evaluated at least once. Could be named is Sometimes()

func Version

func Version() string

Version provides the latest version id of the Anithesis SDK for Go

Types

type AssertInfo

type AssertInfo struct {
	Hit        bool           `json:"hit"`
	MustHit    bool           `json:"must_hit"`
	ExpectType string         `json:"expect_type"`
	Expecting  bool           `json:"expecting"`
	Category   string         `json:"category"`
	Message    string         `json:"message"`
	Condition  bool           `json:"condition"`
	Id         string         `json:"id"`
	Location   *LocationInfo  `json:"location"`
	Details    map[string]any `json:"details"`
}

type LocationInfo

type LocationInfo struct {
	Classname string `json:"classname"`
	Funcname  string `json:"function"`
	Filename  string `json:"filename"`
	Line      int    `json:"line"`
	Column    int    `json:"column"`
}

LocationInfo represents the attributes known at instrumentation time for each Antithesis assertion discovered

func NewLocInfo

func NewLocInfo(classname, funcname, filename string, line int) *LocationInfo

NewLocInfo creates a LocationInfo from values known outside of the current execution context

func NewLocationInfo

func NewLocationInfo(nframes StackFrameOffset) *LocationInfo

NewLocationInfo creates a LocationInfo directly from the current execution context

type StackFrameOffset

type StackFrameOffset int

StackFrameOffset indicates how many frames to go up in the call stack to find the filename/location/line info. As this work is always done in NewLocationInfo(), the offset is specified from the perspective of NewLocationInfo

const (
	OffsetNewLocationInfo StackFrameOffset = iota
	OffsetHere
	OffsetAPICaller
	OffsetAPICallersCaller
)

Order is important here since iota is being used

Jump to

Keyboard shortcuts

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