testutil

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package testutil provides common test utilities for the Starport project

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEventually

func AssertEventually(t *testing.T, condition func() bool, timeout time.Duration, message string)

AssertEventually asserts that a condition becomes true within the timeout

func Eventually

func Eventually(condition func() bool, timeout time.Duration) bool

Eventually runs a function repeatedly until it returns true or the timeout is reached This is similar to WaitFor but returns a boolean instead of failing the test

func WaitFor

func WaitFor(t *testing.T, condition func() bool, timeout time.Duration, message string)

WaitFor polls a condition function until it returns true or the timeout is reached. It's useful for replacing time.Sleep in tests with a more deterministic approach.

func WaitForChannel

func WaitForChannel[T any](t *testing.T, ch <-chan T, timeout time.Duration) T

WaitForChannel waits for a value to be received on a channel

func WaitForExpiration

func WaitForExpiration(t *testing.T, store StorageGetter, key string, timeout time.Duration)

WaitForExpiration waits for a key to expire in storage

func WaitForKeyNotExists

func WaitForKeyNotExists(t *testing.T, store StorageGetter, key string, timeout time.Duration)

WaitForKeyNotExists waits for a key to not exist in storage

func WaitForServer

func WaitForServer(t *testing.T, url string, timeout time.Duration)

WaitForServer waits for a server to be ready by checking a health endpoint

Types

type StorageGetter

type StorageGetter interface {
	Get(ctx context.Context, key string) ([]byte, error)
	Exists(ctx context.Context, key string) (bool, error)
}

StorageGetter is an interface for storage Get operations

Jump to

Keyboard shortcuts

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