Documentation
¶
Overview ¶
Package testing provides test utilities, fixtures, and database setup for HR System services. It includes testcontainers integration for isolated testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestContext ¶
TestContext provides a context with test values.
Types ¶
type AssertionHelpers ¶
type AssertionHelpers struct {
// contains filtered or unexported fields
}
AssertionHelpers provides common test assertions.
func NewAssertionHelpers ¶
func NewAssertionHelpers(t *testing.T) *AssertionHelpers
NewAssertionHelpers creates a new assertion helpers instance.
func (*AssertionHelpers) AssertRecordCount ¶
func (ah *AssertionHelpers) AssertRecordCount(db *gorm.DB, table string, expectedCount int64)
AssertRecordCount checks the number of records in a table.
func (*AssertionHelpers) AssertRecordExists ¶
func (ah *AssertionHelpers) AssertRecordExists(db *gorm.DB, table, column, value string)
AssertRecordExists checks if a record exists in the database.
func (*AssertionHelpers) AssertRecordNotExists ¶
func (ah *AssertionHelpers) AssertRecordNotExists(db *gorm.DB, table, column, value string)
AssertRecordNotExists checks if a record does not exist in the database.
type MockData ¶
type MockData struct{}
MockData provides methods for generating mock test data.
func (*MockData) GenerateEmail ¶
GenerateEmail generates a test email address.
func (*MockData) GenerateEmployeeNumber ¶
GenerateEmployeeNumber generates a test employee number.
func (*MockData) GenerateID ¶
GenerateID generates a test ID.
type SeedData ¶
type SeedData struct {
// contains filtered or unexported fields
}
SeedData provides methods for seeding test data.
func NewSeedData ¶
NewSeedData creates a new seed data helper.
func (*SeedData) CreateEmployee ¶
CreateEmployee creates a test employee.
func (*SeedData) CreateTenant ¶
CreateTenant creates a test tenant.
type TestDatabase ¶
type TestDatabase struct {
DB *gorm.DB
Container *postgres.PostgresContainer
Config config.DatabaseConfig
}
TestDatabase represents a test database instance.
func SetupTestDB ¶
func SetupTestDB(t *testing.T) *TestDatabase
SetupTestDB creates a test database using testcontainers.
func SetupTestDBWithModels ¶
func SetupTestDBWithModels(t *testing.T, models ...interface{}) *TestDatabase
SetupTestDBWithModels creates a test database and runs migrations for the given models.
func (*TestDatabase) TruncateAllTables ¶
func (td *TestDatabase) TruncateAllTables() error
TruncateAllTables truncates all tables in the test database.
func (*TestDatabase) TruncateTable ¶
func (td *TestDatabase) TruncateTable(tableName string) error
TruncateTable truncates a table for test cleanup.
type TestFixtures ¶
TestFixtures provides common test fixtures.
func NewTestFixtures ¶
func NewTestFixtures(db *gorm.DB) *TestFixtures
NewTestFixtures creates a new test fixtures helper.
func (*TestFixtures) SetupBasicFixtures ¶
func (tf *TestFixtures) SetupBasicFixtures() error
SetupBasicFixtures creates basic test data (tenant, user, employee).