testutil

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocateFreePort added in v0.1.15

func AllocateFreePort() (int, error)

AllocateFreePort picks a free TCP port on 127.0.0.1 by binding to :0 then immediately releasing the socket. Callers should be aware of the inherent TIME_WAIT race on Darwin: re-binding the returned port in the same process within a few milliseconds can occasionally fail with "address already in use" when the kernel hands it to another concurrent goroutine before the original listener's close fully propagates. In practice the 10 ms sleep injected by server.StartWith plus per-port randomization inside Go's `net` package is enough to keep the window tiny.

func AllocateTwoFreePorts added in v0.1.15

func AllocateTwoFreePorts(tb testing.TB) (appPort, ctrlPort int)

AllocateTwoFreePorts returns two distinct free TCP ports on 127.0.0.1. The two ports are NEVER equal even if a transient listener release leaves an overlap window for the second allocate.

func AssertBucketDistribution added in v0.1.13

func AssertBucketDistribution(t AssertableT, idsA, idsC, allIDs []string)

func AssertGtGteGap1 added in v0.1.13

func AssertGtGteGap1(t AssertableT, gteIDs []string, gtIDs []string, boundary string)

func AssertKeyRangeRunResult added in v0.1.13

func AssertKeyRangeRunResult(t AssertableT, caseName, label string, wantAsc []string, ids []string, ok bool, errMsg string, desc bool)

func AssertLtLteGap1 added in v0.1.13

func AssertLtLteGap1(t AssertableT, lteIDs []string, ltIDs []string, boundary string)

func AssertScoreEqSKId added in v0.1.13

func AssertScoreEqSKId(t AssertableT, siAsc, skAsc, siDesc, skDesc []string)

func AssertSearchIndexMatrix added in v0.1.13

func AssertSearchIndexMatrix(t AssertableT, run SearchIndexRunFn, idxName string, cases []KeyRangeCtorCase, idFn func(string) string, caseNamePrefix string)

func AssertSearchKeyMatrix added in v0.1.13

func AssertSearchKeyMatrix(t AssertableT, run SearchKeyRunFn, cases []KeyRangeCtorCase, idFn func(string) string, caseNamePrefix string)

func AssertSparseLimit10 added in v0.1.13

func AssertSparseLimit10(t AssertableT, siIDs []string)

func CountX added in v0.1.13

func CountX() int

func DBPath

func DBPath(tb testing.TB) string

DBPath returns one temporary database file path for tests.

func KeyRangeDocKeyAttrs added in v0.1.13

func KeyRangeDocKeyAttrs() []string

func KeyRangeDocTTL added in v0.1.13

func KeyRangeDocTTL() time.Duration

func KeyRangeFixtureMem added in v0.1.13

func KeyRangeFixtureMem() bool

func KeyRangeIndexName added in v0.1.13

func KeyRangeIndexName(namespace string, mem bool, name string) string

func KeyRangeKeyPattern added in v0.1.13

func KeyRangeKeyPattern(namespace string, mem bool) string

func KeyRangeRawIndexes added in v0.1.13

func KeyRangeRawIndexes(namespace string, mem bool) []x.Index

func LoadFeature

func LoadFeature(t *testing.T) string

LoadFeature dynamically loads a JSON file based on the calling test's context. The file name format is: {SuiteName}_{TestMethodName}_{CaseName}.json All spaces in the case name are replaced with underscores. Example: UpdateSuite_TestUpdateCases_Update_existing_property.json

func XFirstN added in v0.1.13

func XFirstN(ids []string, n int) []string

func XIDKey added in v0.1.13

func XIDKey(namespace string, mem bool, id string) string

func XIDsFromValues added in v0.1.13

func XIDsFromValues(values []string) []string

func XKeyPrefix added in v0.1.13

func XKeyPrefix(namespace string, mem bool) string

func XLastN added in v0.1.13

func XLastN(ids []string, n int) []string

func XRangeIDs added in v0.1.13

func XRangeIDs(lo, hi int) []string

func XReverseIDs added in v0.1.13

func XReverseIDs(asc []string) []string

func XStrictMonotonic added in v0.1.13

func XStrictMonotonic(ids []string, desc bool) bool

Types

type AssertableT added in v0.1.13

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

type KV added in v0.1.13

type KV struct {
	K string
	V string
}

func LoadX added in v0.1.13

func LoadX(tb testing.TB) []KV

func LoadXFor added in v0.1.13

func LoadXFor(tb testing.TB, namespace string, mem bool) []KV

type KeyRangeCtorCase added in v0.1.13

type KeyRangeCtorCase struct {
	Name    string
	Build   func(idFn func(string) string) x.KeyRange
	WantAsc []string
}

func KeyRangeCtorCases added in v0.1.13

func KeyRangeCtorCases() []KeyRangeCtorCase

type SearchIndexRunFn added in v0.1.13

type SearchIndexRunFn = func(idxName string, kr x.KeyRange, desc bool) (ids []string, ok bool, errMsg string)

type SearchKeyRunFn added in v0.1.13

type SearchKeyRunFn = func(kr x.KeyRange, desc bool) (ids []string, ok bool, errMsg string)

type TestDoc added in v0.1.13

type TestDoc string

func LoadXRaw added in v0.1.13

func LoadXRaw(tb testing.TB) []TestDoc

func (TestDoc) KeyAttrs added in v0.1.13

func (TestDoc) KeyAttrs() []string

func (TestDoc) Mem added in v0.1.13

func (TestDoc) Mem() bool

func (TestDoc) Namespace added in v0.1.13

func (TestDoc) Namespace() string

func (TestDoc) RawJSON added in v0.1.13

func (d TestDoc) RawJSON() string

func (TestDoc) TTL added in v0.1.13

func (TestDoc) TTL() time.Duration

Jump to

Keyboard shortcuts

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