tests

package
v0.0.0-...-e77b5a0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 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 DoesNotHaveItem

func DoesNotHaveItem(it vocab.Item) itemCheckFn

func EndOK

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

func EqErrs

func EqErrs(want, got error) bool

func HasActor

func HasActor(u ...vocab.Item) itemCheckFn

func HasAnyOf

func HasAnyOf(u ...vocab.Item) itemCheckFn

func HasAttributedTo

func HasAttributedTo(u ...vocab.Item) itemCheckFn

func HasAudience

func HasAudience(u ...vocab.Item) itemCheckFn

func HasCC

func HasCC(cc ...vocab.Item) itemCheckFn

func HasContent

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

func HasContext

func HasContext(u ...vocab.Item) itemCheckFn

func HasEndpoints

func HasEndpoints(e *vocab.Endpoints) itemCheckFn

func HasExactItems

func HasExactItems(items ...vocab.Item) itemCheckFn

func HasFormerType

func HasFormerType(typ vocab.Typer) itemCheckFn

func HasID

func HasID(want vocab.IRI) itemCheckFn

func HasInReplyTo

func HasInReplyTo(u ...vocab.Item) itemCheckFn

func HasInbox

func HasInbox(want vocab.IRI) itemCheckFn

func HasItem

func HasItem(it vocab.Item) itemCheckFn

func HasMediaType

func HasMediaType(mt vocab.MimeType) itemCheckFn

func HasName

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

func HasObject

func HasObject(u ...vocab.Item) itemCheckFn

func HasOneOf

func HasOneOf(u ...vocab.Item) itemCheckFn

func HasOrigin

func HasOrigin(u ...vocab.Item) itemCheckFn

func HasOutbox

func HasOutbox(want vocab.IRI) itemCheckFn

func HasPreferredUsername

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

func HasProxyURL

func HasProxyURL(iri vocab.IRI) itemCheckFn

func HasPublicKey

func HasPublicKey(pub vocab.PublicKey) itemCheckFn

func HasReplies

func HasReplies(want vocab.IRI) itemCheckFn

func HasSharedInbox

func HasSharedInbox(iri vocab.Item) itemCheckFn

func HasSource

func HasSource[T ~string | vocab.NaturalLanguageValues](cont T, mt vocab.MimeType) itemCheckFn

func HasStreams

func HasStreams(u ...vocab.Item) itemCheckFn

func HasSummary

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

func HasTag

func HasTag(u vocab.Item) itemCheckFn

func HasTarget

func HasTarget(u ...vocab.Item) itemCheckFn

func HasTo

func HasTo(to ...vocab.Item) itemCheckFn

func HasTotalItems

func HasTotalItems(cnt int) itemCheckFn

func HasURL

func HasURL(u ...vocab.Item) itemCheckFn

func IsType

func IsType(typ vocab.Typer) itemCheckFn

func MatchToken

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

func Request

func Request() *reqBuilder

func Response

func Response() resChecks

func WasDeleted

func WasDeleted(d time.Time) itemCheckFn

func WasPublished

func WasPublished(d time.Time) itemCheckFn

func WasUpdated

func WasUpdated(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