Documentation
¶
Index ¶
- func AssertStatusCode(t *testing.T, resp *http.Response, expected int)
- func CleanupTestDB(t *testing.T, pool *pgxpool.Pool)
- func CreateAuthToken(t *testing.T, userID, email string, roles []string) string
- func CreateMockEmailService(t *testing.T) *email.EmailService
- func CreateTestAPIKey(t *testing.T, pool *pgxpool.Pool, userID uuid.UUID, name string) uuid.UUID
- func CreateTestUser(t *testing.T, pool *pgxpool.Pool, email, password, name string) uuid.UUID
- func LoadFixture(t *testing.T, filename string, key string) map[string]interface{}
- func LoadFixtureRaw(t *testing.T, filename string) []byte
- func MakeRequest(t *testing.T, method, url string, body interface{}, token string) *http.Response
- func ParseResponse(t *testing.T, resp *http.Response, v interface{})
- func SetupTestDB(t *testing.T) *pgxpool.Pool
- func SkipIfNoPostgres(t *testing.T)
- func SkipIfNoRedis(t *testing.T)
- func SkipIfShort(t *testing.T)
- type MockEmailService
- type SentEmail
- type TestConfig
- type TestServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertStatusCode ¶
AssertStatusCode asserts the response status code
func CleanupTestDB ¶
CleanupTestDB cleans up test database
func CreateAuthToken ¶
CreateAuthToken creates a test JWT token
func CreateMockEmailService ¶
func CreateMockEmailService(t *testing.T) *email.EmailService
CreateMockEmailService creates a mock email service
func CreateTestAPIKey ¶
CreateTestAPIKey creates a test API key
func CreateTestUser ¶
CreateTestUser creates a test user in the database
func LoadFixture ¶
LoadFixture loads a fixture from the fixtures directory
func LoadFixtureRaw ¶
LoadFixtureRaw loads a fixture file as raw bytes
func MakeRequest ¶
MakeRequest makes an HTTP request to the test server
func ParseResponse ¶
ParseResponse parses JSON response body
func SetupTestDB ¶
SetupTestDB creates a test database connection
func SkipIfNoPostgres ¶
SkipIfNoPostgres skips the test if PostgreSQL is not available
func SkipIfNoRedis ¶
SkipIfNoRedis skips the test if Redis is not available
Types ¶
type MockEmailService ¶
type MockEmailService struct {
SentEmails []SentEmail
}
MockEmailService is a mock implementation of email service This can be extended to track sent emails for testing
func (*MockEmailService) ClearSentEmails ¶
func (m *MockEmailService) ClearSentEmails()
ClearSentEmails clears the sent emails list
func (*MockEmailService) GetSentEmails ¶
func (m *MockEmailService) GetSentEmails() []SentEmail
GetSentEmails returns all sent emails
func (*MockEmailService) SendEmail ¶
func (m *MockEmailService) SendEmail(to, subject, body string) error
SendEmail mocks sending an email
type TestConfig ¶
TestConfig holds test configuration
func GetTestConfig ¶
func GetTestConfig(t *testing.T) *TestConfig
GetTestConfig loads test configuration from environment or defaults
type TestServer ¶
TestServer wraps a test HTTP server
func CreateTestServer ¶
func CreateTestServer(t *testing.T, setupRouter func(*gin.Engine)) *TestServer
CreateTestServer creates a test HTTP server