Documentation
¶
Index ¶
- func AssertEqual[T comparable](t *testing.T, expected, actual T, msg string, args ...interface{})
- func AssertError(t *testing.T, err error, msg string, args ...interface{})
- func AssertFalse(t *testing.T, condition bool, msg string, args ...interface{})
- func AssertNoError(t *testing.T, err error, msg string, args ...interface{})
- func AssertNotEqual[T comparable](t *testing.T, expected, actual T, msg string, args ...interface{})
- func AssertTrue(t *testing.T, condition bool, msg string, args ...interface{})
- type DataFactory
- func (df *DataFactory) CreateTestAccount(t *testing.T, id uint32, email string)
- func (df *DataFactory) CreateTestLogScore(t *testing.T, serverID, monitorID uint32, score, step float64, rtt *int32, ...)
- func (df *DataFactory) CreateTestMonitor(t *testing.T, id uint32, tlsName string, accountID uint32, ip string, ...)
- func (df *DataFactory) CreateTestMonitorWithType(t *testing.T, id uint32, tlsName string, accountID uint32, ip string, ...)
- func (df *DataFactory) CreateTestServer(t *testing.T, id uint32, ip string, ipVersion string, accountID *uint32)
- func (df *DataFactory) CreateTestServerScore(t *testing.T, serverID, monitorID uint32, status string, scoreRaw float64)
- func (df *DataFactory) SetSystemSetting(t *testing.T, key, value string)
- type TestDB
- type TestLogger
- type TimeController
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEqual ¶
func AssertEqual[T comparable](t *testing.T, expected, actual T, msg string, args ...interface{})
AssertEqual is a helper to assert two values are equal
func AssertError ¶
AssertError is a helper to assert an error occurred
func AssertFalse ¶
AssertFalse is a helper to assert a boolean is false
func AssertNoError ¶
AssertNoError is a helper to assert no error occurred
func AssertNotEqual ¶
func AssertNotEqual[T comparable](t *testing.T, expected, actual T, msg string, args ...interface{})
AssertNotEqual is a helper to assert two values are not equal
Types ¶
type DataFactory ¶
type DataFactory struct {
// contains filtered or unexported fields
}
DataFactory helps generate realistic test data
func NewDataFactory ¶
func NewDataFactory(tdb *TestDB) *DataFactory
NewDataFactory creates a new data factory
func (*DataFactory) CreateTestAccount ¶
func (df *DataFactory) CreateTestAccount(t *testing.T, id uint32, email string)
CreateTestAccount creates a test account
func (*DataFactory) CreateTestLogScore ¶
func (df *DataFactory) CreateTestLogScore(t *testing.T, serverID, monitorID uint32, score, step float64, rtt *int32, ts time.Time)
CreateTestLogScore creates a test log score
func (*DataFactory) CreateTestMonitor ¶
func (df *DataFactory) CreateTestMonitor(t *testing.T, id uint32, tlsName string, accountID uint32, ip string, status string)
CreateTestMonitor creates a test monitor
func (*DataFactory) CreateTestMonitorWithType ¶
func (df *DataFactory) CreateTestMonitorWithType(t *testing.T, id uint32, tlsName string, accountID uint32, ip string, status string, monitorType string)
CreateTestMonitorWithType creates a test monitor with specified type
func (*DataFactory) CreateTestServer ¶
func (df *DataFactory) CreateTestServer(t *testing.T, id uint32, ip string, ipVersion string, accountID *uint32)
CreateTestServer creates a test server
func (*DataFactory) CreateTestServerScore ¶
func (df *DataFactory) CreateTestServerScore(t *testing.T, serverID, monitorID uint32, status string, scoreRaw float64)
CreateTestServerScore creates a test server score
func (*DataFactory) SetSystemSetting ¶
func (df *DataFactory) SetSystemSetting(t *testing.T, key, value string)
SetSystemSetting sets a system setting for tests
type TestDB ¶
TestDB represents a test database connection with utilities
func (*TestDB) CleanupTestData ¶
CleanupTestData removes all test data from the database
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
TestLogger creates a test logger that outputs to testing.T
func NewTestLogger ¶
func NewTestLogger(t *testing.T) *TestLogger
NewTestLogger creates a test logger
func (*TestLogger) Logger ¶
func (tl *TestLogger) Logger() *slog.Logger
Logger returns the slog.Logger instance
type TimeController ¶
type TimeController struct {
// contains filtered or unexported fields
}
TimeController allows controlling time in tests
func NewTimeController ¶
func NewTimeController() *TimeController
NewTimeController creates a new time controller
func (*TimeController) Advance ¶
func (tc *TimeController) Advance(d time.Duration)
Advance advances time by the given duration
func (*TimeController) Freeze ¶
func (tc *TimeController) Freeze()
Freeze freezes time at the current moment
func (*TimeController) Now ¶
func (tc *TimeController) Now() time.Time
Now returns the current controlled time
func (*TimeController) SetTime ¶
func (tc *TimeController) SetTime(t time.Time)
SetTime sets the current time