tests

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 12 Imported by: ? 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

Overview

Package tests provides test utilities and fixtures for Ason.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertAllSuccess

func AssertAllSuccess(t testing.TB, results []ConcurrencyResult)

AssertAllSuccess checks that all concurrent operations succeeded.

func AssertNoRaceCondition

func AssertNoRaceCondition(t testing.TB, results []ConcurrencyResult)

AssertNoRaceCondition checks for signs of race conditions. It verifies that operations don't have overlapping execution times (for write operations).

func AssertSuccessCount

func AssertSuccessCount(t testing.TB, results []ConcurrencyResult, count int)

AssertSuccessCount checks that exactly count operations succeeded.

func MeasureConcurrencyThroughput

func MeasureConcurrencyThroughput(results []ConcurrencyResult) float64

MeasureConcurrencyThroughput measures the throughput of concurrent operations. It returns the number of operations per second.

func TestGenerateConcurrent

func TestGenerateConcurrent(t *testing.T)

TestGenerateConcurrent tests concurrent generation with multiple goroutines

func TestGenerateValidation

func TestGenerateValidation(t *testing.T)

TestGenerateValidation tests input validation

func TestGenerateWithContext

func TestGenerateWithContext(t *testing.T)

TestGenerateWithContext tests context cancellation

func TestGenerateWithTimeout

func TestGenerateWithTimeout(t *testing.T)

TestGenerateWithTimeout tests timeout behavior

func TestGetEngine

func TestGetEngine(t *testing.T)

TestGetEngine verifies GetEngine returns the correct engine

func TestInvalidArgumentError

func TestInvalidArgumentError(t *testing.T)

TestInvalidArgumentError verifies error formatting

func TestListEmpty

func TestListEmpty(t *testing.T)

TestListEmpty tests listing empty registry

func TestNewGenerator

func TestNewGenerator(t *testing.T)

TestNewGenerator tests Generator creation

func TestNewRegistry

func TestNewRegistry(t *testing.T)

TestNewRegistry tests Registry creation with default path

func TestNewRegistryAt

func TestNewRegistryAt(t *testing.T)

TestNewRegistryAt tests Registry creation with custom path

func TestNewRegistryAtEmptyPath

func TestNewRegistryAtEmptyPath(t *testing.T)

TestNewRegistryAtEmptyPath tests Registry creation with empty path

func TestRegisterEmptyName

func TestRegisterEmptyName(t *testing.T)

TestRegisterEmptyName tests registering with empty name

func TestRegisterEmptyPath

func TestRegisterEmptyPath(t *testing.T)

TestRegisterEmptyPath tests registering with empty path

func TestRegisterInvalidName

func TestRegisterInvalidName(t *testing.T)

TestRegisterInvalidName tests registering with invalid name format

func TestRegisterMultipleTemplates

func TestRegisterMultipleTemplates(t *testing.T)

TestRegisterMultipleTemplates tests registering multiple templates

func TestRegisterNonexistentPath

func TestRegisterNonexistentPath(t *testing.T)

TestRegisterNonexistentPath tests registering non-existent path

func TestRegisterOverwrite

func TestRegisterOverwrite(t *testing.T)

TestRegisterOverwrite tests overwriting an existing template

func TestRegisterTemplate

func TestRegisterTemplate(t *testing.T)

TestRegisterTemplate tests registering a new template

func TestRegistryConcurrentReads

func TestRegistryConcurrentReads(t *testing.T)

TestRegistryConcurrentReads tests concurrent read operations

func TestRegistryConcurrentWrites

func TestRegistryConcurrentWrites(t *testing.T)

TestRegistryConcurrentWrites tests concurrent write operations (should serialize)

func TestRegistryPersistence

func TestRegistryPersistence(t *testing.T)

TestRegistryPersistence tests that registry survives close/reopen

func TestRemoveNonexistent

func TestRemoveNonexistent(t *testing.T)

TestRemoveNonexistent tests removing a non-existent template (should be idempotent)

func TestRemoveTemplate

func TestRemoveTemplate(t *testing.T)

TestRemoveTemplate tests removing a template

func WaitForCondition

func WaitForCondition(t testing.TB, timeout time.Duration, condition func() bool) bool

WaitForCondition waits for a condition to become true, with timeout.

Types

type ConcurrencyResult

type ConcurrencyResult struct {
	OperationIndex int
	Success        bool
	Error          error
	StartTime      time.Time
	EndTime        time.Time
	Duration       time.Duration
}

ConcurrencyResult tracks the results of concurrent operations.

func RunConcurrent

func RunConcurrent(t testing.TB, numConcurrent int, fn func(index int) error) []ConcurrencyResult

RunConcurrent executes a function concurrently and collects results. It runs the function numConcurrent times in parallel and waits for all to complete.

type ConcurrentCounter

type ConcurrentCounter struct {
	// contains filtered or unexported fields
}

ConcurrentCounter is a thread-safe counter for concurrent operations.

func NewConcurrentCounter

func NewConcurrentCounter() *ConcurrentCounter

NewConcurrentCounter creates a new counter.

func (*ConcurrentCounter) Increment

func (c *ConcurrentCounter) Increment()

Increment adds 1 to the counter.

func (*ConcurrentCounter) Reset

func (c *ConcurrentCounter) Reset()

Reset resets the counter to 0.

func (*ConcurrentCounter) Value

func (c *ConcurrentCounter) Value() int64

Value returns the current counter value.

type ErrorCollector

type ErrorCollector struct {
	// contains filtered or unexported fields
}

ErrorCollector collects errors from concurrent operations.

func NewErrorCollector

func NewErrorCollector() *ErrorCollector

NewErrorCollector creates a new error collector.

func (*ErrorCollector) Add

func (ec *ErrorCollector) Add(err error)

Add adds an error to the collection.

func (*ErrorCollector) Errors

func (ec *ErrorCollector) Errors() []error

Errors returns all collected errors.

func (*ErrorCollector) HasErrors

func (ec *ErrorCollector) HasErrors() bool

HasErrors returns true if any errors were collected.

func (*ErrorCollector) String

func (ec *ErrorCollector) String() string

String returns a formatted string of all errors.

Directories

Path Synopsis
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

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