asserts

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package asserts holds tiny test assertion helpers shared across botbooter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckBannedImports added in v0.3.0

func CheckBannedImports(t TestingT, dir string, banned []string, label string)

CheckBannedImports parses every non-test Go file in dir and fails t if any file imports a path containing one of the banned substrings. label names the package for error messages (e.g. "cli", "core"). It is the shared body of the per-package import guards that lock in the platform-SDK decoupling.

func Equal

func Equal[T comparable](t TestingT, got, expected T, message string)

Equal fails the test with message if got is not equal to expected.

func Error

func Error(t TestingT, err error, message string)

Error fails the test with message if err is nil.

func ErrorIs

func ErrorIs(t TestingT, err, target error, message string)

ErrorIs fails the test with message if err does not match target under errors.Is.

func False

func False(t TestingT, got bool, message string)

False fails the test with message if got is true.

func NoError

func NoError(t TestingT, err error, message string)

NoError fails the test with message if err is non-nil.

func NotNil

func NotNil(t TestingT, got any, message string)

NotNil fails the test with message if got is nil.

func True

func True(t TestingT, got bool, message string)

True fails the test with message if got is false.

Types

type TestingT added in v0.3.0

type TestingT interface {
	Helper()
	Errorf(format string, args ...any)
}

TestingT is the subset of *testing.T the assertions use. Accepting the interface (which *testing.T satisfies) lets the helpers themselves be unit-tested with a recording fake.

Jump to

Keyboard shortcuts

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