Documentation
¶
Index ¶
- func TestPatternsSuite(t *testing.T)
- type BaseTestSuite
- func (s *BaseTestSuite) AddCleanup(cleanup func() error)
- func (s *BaseTestSuite) RetryOperation(description string, operation func() error) error
- func (s *BaseTestSuite) SetupSuite()
- func (s *BaseTestSuite) SetupTest()
- func (s *BaseTestSuite) TearDownTest()
- func (s *BaseTestSuite) WaitForCondition(description string, condition func() bool) bool
- func (s *BaseTestSuite) WaitForConditionWithTimeout(description string, condition func() bool, timeout time.Duration) bool
- type MockConnection
- type MockRateLimiter
- type MockTimeKeeper
- type ResourceCleanupTestSuite
- type TimingDependentTestSuite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestPatternsSuite ¶
TestPatternsSuite runs the patterns test suite.
Types ¶
type BaseTestSuite ¶
BaseTestSuite provides consistent test patterns and utilities.
func (*BaseTestSuite) AddCleanup ¶
func (s *BaseTestSuite) AddCleanup(cleanup func() error)
AddCleanup adds a cleanup function to be called during teardown.
func (*BaseTestSuite) RetryOperation ¶
func (s *BaseTestSuite) RetryOperation(description string, operation func() error) error
RetryOperation retries an operation with exponential backoff.
func (*BaseTestSuite) SetupSuite ¶
func (s *BaseTestSuite) SetupSuite()
SetupSuite runs once before all tests in the suite.
func (*BaseTestSuite) SetupTest ¶
func (s *BaseTestSuite) SetupTest()
SetupTest runs before each test.
func (*BaseTestSuite) TearDownTest ¶
func (s *BaseTestSuite) TearDownTest()
TearDownTest runs after each test.
func (*BaseTestSuite) WaitForCondition ¶
func (s *BaseTestSuite) WaitForCondition(description string, condition func() bool) bool
WaitForCondition waits for a condition to be true with configurable timeout and retry.
func (*BaseTestSuite) WaitForConditionWithTimeout ¶
func (s *BaseTestSuite) WaitForConditionWithTimeout( description string, condition func() bool, timeout time.Duration, ) bool
WaitForConditionWithTimeout waits for condition with specific timeout.
type MockConnection ¶
type MockConnection struct {
// contains filtered or unexported fields
}
MockConnection provides a mock connection for testing.
func NewMockConnection ¶
func NewMockConnection() *MockConnection
NewMockConnection creates a new mock connection.
func (*MockConnection) Disconnect ¶
func (c *MockConnection) Disconnect()
Disconnect simulates a connection failure.
func (*MockConnection) IsConnected ¶
func (c *MockConnection) IsConnected() bool
IsConnected returns whether the connection is active.
type MockRateLimiter ¶
type MockRateLimiter struct {
// contains filtered or unexported fields
}
MockRateLimiter provides rate limiting for testing.
func NewMockRateLimiter ¶
func NewMockRateLimiter(requestsPerSecond int) *MockRateLimiter
NewMockRateLimiter creates a new mock rate limiter.
func (*MockRateLimiter) Allow ¶
func (r *MockRateLimiter) Allow() bool
Allow checks if a request is allowed under the current rate limit.
type MockTimeKeeper ¶
type MockTimeKeeper struct {
// contains filtered or unexported fields
}
MockTimeKeeper provides controlled time for testing.
func NewMockTimeKeeper ¶
func NewMockTimeKeeper() *MockTimeKeeper
NewMockTimeKeeper creates a new mock time keeper.
func (*MockTimeKeeper) Advance ¶
func (m *MockTimeKeeper) Advance(d time.Duration)
Advance advances the mock time by the specified duration.
func (*MockTimeKeeper) Now ¶
func (m *MockTimeKeeper) Now() time.Time
Now returns the current mock time.
type ResourceCleanupTestSuite ¶
type ResourceCleanupTestSuite struct {
BaseTestSuite
// contains filtered or unexported fields
}
ResourceCleanupTestSuite provides testing patterns for resource cleanup.
func (*ResourceCleanupTestSuite) TestConcurrentResourceCleanup ¶
func (s *ResourceCleanupTestSuite) TestConcurrentResourceCleanup()
TestConcurrentResourceCleanup demonstrates concurrent resource cleanup patterns.
func (*ResourceCleanupTestSuite) TestFileResourceCleanup ¶
func (s *ResourceCleanupTestSuite) TestFileResourceCleanup()
TestFileResourceCleanup demonstrates proper file resource cleanup.
type TimingDependentTestSuite ¶
type TimingDependentTestSuite struct {
BaseTestSuite
// contains filtered or unexported fields
}
TimingDependentTestSuite provides testing patterns for timing-sensitive tests.
func (*TimingDependentTestSuite) SetupTest ¶
func (s *TimingDependentTestSuite) SetupTest()
SetupTest initializes timing-dependent test resources.
func (*TimingDependentTestSuite) TestRateLimitingPatterns ¶
func (s *TimingDependentTestSuite) TestRateLimitingPatterns()
TestRateLimitingPatterns demonstrates improved rate limiting testing.
func (*TimingDependentTestSuite) TestRetryLogicImproved ¶
func (s *TimingDependentTestSuite) TestRetryLogicImproved()
TestRetryLogicImproved demonstrates improved retry testing patterns.