Documentation
¶
Overview ¶
Package tests provides test utilities and fixtures for Ason.
Index ¶
- func AssertAllSuccess(t testing.TB, results []ConcurrencyResult)
- func AssertNoRaceCondition(t testing.TB, results []ConcurrencyResult)
- func AssertSuccessCount(t testing.TB, results []ConcurrencyResult, count int)
- func MeasureConcurrencyThroughput(results []ConcurrencyResult) float64
- func TestGenerateConcurrent(t *testing.T)
- func TestGenerateValidation(t *testing.T)
- func TestGenerateWithContext(t *testing.T)
- func TestGenerateWithTimeout(t *testing.T)
- func TestGetEngine(t *testing.T)
- func TestInvalidArgumentError(t *testing.T)
- func TestListEmpty(t *testing.T)
- func TestNewGenerator(t *testing.T)
- func TestNewRegistry(t *testing.T)
- func TestNewRegistryAt(t *testing.T)
- func TestNewRegistryAtEmptyPath(t *testing.T)
- func TestRegisterEmptyName(t *testing.T)
- func TestRegisterEmptyPath(t *testing.T)
- func TestRegisterInvalidName(t *testing.T)
- func TestRegisterMultipleTemplates(t *testing.T)
- func TestRegisterNonexistentPath(t *testing.T)
- func TestRegisterOverwrite(t *testing.T)
- func TestRegisterTemplate(t *testing.T)
- func TestRegistryConcurrentReads(t *testing.T)
- func TestRegistryConcurrentWrites(t *testing.T)
- func TestRegistryPersistence(t *testing.T)
- func TestRemoveNonexistent(t *testing.T)
- func TestRemoveTemplate(t *testing.T)
- func WaitForCondition(t testing.TB, timeout time.Duration, condition func() bool) bool
- type ConcurrencyResult
- type ConcurrentCounter
- type ErrorCollector
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 ¶
TestGenerateConcurrent tests concurrent generation with multiple goroutines
func TestGenerateValidation ¶
TestGenerateValidation tests input validation
func TestGenerateWithContext ¶
TestGenerateWithContext tests context cancellation
func TestGenerateWithTimeout ¶
TestGenerateWithTimeout tests timeout behavior
func TestGetEngine ¶
TestGetEngine verifies GetEngine returns the correct engine
func TestInvalidArgumentError ¶
TestInvalidArgumentError verifies error formatting
func TestNewGenerator ¶
TestNewGenerator tests Generator creation
func TestNewRegistry ¶
TestNewRegistry tests Registry creation with default path
func TestNewRegistryAt ¶
TestNewRegistryAt tests Registry creation with custom path
func TestNewRegistryAtEmptyPath ¶
TestNewRegistryAtEmptyPath tests Registry creation with empty path
func TestRegisterEmptyName ¶
TestRegisterEmptyName tests registering with empty name
func TestRegisterEmptyPath ¶
TestRegisterEmptyPath tests registering with empty path
func TestRegisterInvalidName ¶
TestRegisterInvalidName tests registering with invalid name format
func TestRegisterMultipleTemplates ¶
TestRegisterMultipleTemplates tests registering multiple templates
func TestRegisterNonexistentPath ¶
TestRegisterNonexistentPath tests registering non-existent path
func TestRegisterOverwrite ¶
TestRegisterOverwrite tests overwriting an existing template
func TestRegisterTemplate ¶
TestRegisterTemplate tests registering a new template
func TestRegistryConcurrentReads ¶
TestRegistryConcurrentReads tests concurrent read operations
func TestRegistryConcurrentWrites ¶
TestRegistryConcurrentWrites tests concurrent write operations (should serialize)
func TestRegistryPersistence ¶
TestRegistryPersistence tests that registry survives close/reopen
func TestRemoveNonexistent ¶
TestRemoveNonexistent tests removing a non-existent template (should be idempotent)
func TestRemoveTemplate ¶
TestRemoveTemplate tests removing a template
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 ¶
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.