tests

package
v0.0.0-...-a607628 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	URLRegexp    = regexp.MustCompile(`((?:http|https)://[a-zA-Z0-9./-]+)`)
	PassMatch    = MatchesString(`Password: `)
	ConfirmMatch = MatchesString(` Confirm: `)
)
View Source
var CR = []byte{'\n'}
View Source
var CRLF = []byte{'\r', '\n'}
View Source
var EquateWeakErrors = cmp.FilterValues(areErrors, cmp.Comparer(compareErrors))

Functions

func AnyOutput

func AnyOutput(t testing.TB, line []byte) []byte

func DiffErrs

func DiffErrs(want, got error) string

func EndOK

func EndOK(t testing.TB, line []byte) []byte

func EqErrs

func EqErrs(want, got error) bool

func HasActor

func HasActor(iri vocab.IRI) itemCheckFn

func HasContent

func HasContent[T ~string | vocab.NaturalLanguageValues](cont T) itemCheckFn

func HasObject

func HasObject(iri vocab.IRI) itemCheckFn

func HasPreferredUsername

func HasPreferredUsername[T ~string | vocab.NaturalLanguageValues](name T) itemCheckFn

func HasURL

func HasURL(u string) itemCheckFn

func IsType

func IsType(typ vocab.ActivityVocabularyType) itemCheckFn

func MatchToken

func MatchToken(t testing.TB, i []byte) []byte

func Request

func Request() *reqBuilder

func Response

func Response() resChecks

func WasPublished

func WasPublished(d time.Time) itemCheckFn

func WithTests

func WithTests(testFns ...LineOutputTest) ioTestFn

Types

type CommandTest

type CommandTest struct {
	Name    string
	Host    string
	Cmd     tc.Executable
	IO      ioTestFn
	WantErr error
}

func (CommandTest) Fn

func (c CommandTest) Fn(ctx context.Context, mocks c.Running) func(t *testing.T)

func (CommandTest) Label

func (c CommandTest) Label() string

func (CommandTest) Run

func (c CommandTest) Run(ctx context.Context, containers c.Running, t *testing.T)

type HTTPTest

type HTTPTest struct {
	Name string
	Req  *reqBuilder
	Res  resChecks
}

func (HTTPTest) Fn

func (ht HTTPTest) Fn(ctx context.Context, mocks c.Running) func(t *testing.T)

func (HTTPTest) Label

func (ht HTTPTest) Label() string

func (HTTPTest) Run

func (ht HTTPTest) Run(ctx context.Context, mocks c.Running, t *testing.T)

type LineOutputTest

type LineOutputTest func(testing.TB, []byte) []byte

func ExtractActorIRI

func ExtractActorIRI(iri *vocab.IRI) LineOutputTest

func GetToken

func GetToken(token *c2s.BearerSigner) LineOutputTest

func MatchesRegexp

func MatchesRegexp(r *regexp.Regexp) LineOutputTest

func MatchesString

func MatchesString(s string) LineOutputTest

func WithInput

func WithInput(r LineOutputTest, input string) LineOutputTest

type RunnableTest

type RunnableTest interface {
	Label() string
	// Run is one way to run the tests directly from a func(*testing.T)
	Run(context.Context, c.Running, *testing.T)
	// Fn is a way to pass the test fn directly to testing.T.Run()
	Fn(context.Context, c.Running) func(*testing.T)
}

type TestSuite

type TestSuite struct {
	Name  string
	Tests []RunnableTest
}

func (TestSuite) Fn

func (ht TestSuite) Fn(ctx context.Context, mocks c.Running) func(t *testing.T)

func (TestSuite) Label

func (ht TestSuite) Label() string

func (TestSuite) Run

func (ht TestSuite) Run(ctx context.Context, mocks c.Running, t *testing.T)

Jump to

Keyboard shortcuts

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