Documentation
¶
Index ¶
- type TestApp
- func (ta *TestApp) Close()
- func (ta *TestApp) Delete(t *testing.T, path string, headers map[string]string) *TestResponse
- func (ta *TestApp) Get(t *testing.T, path string) *TestResponse
- func (ta *TestApp) Post(t *testing.T, path string, body interface{}, headers map[string]string) *TestResponse
- func (ta *TestApp) Put(t *testing.T, path string, body interface{}, headers map[string]string) *TestResponse
- func (ta *TestApp) Request(t *testing.T, method, path string, body interface{}, headers map[string]string) *TestResponse
- type TestAssertion
- type TestConfig
- type TestDataProvider
- func (tdp *TestDataProvider) Clear()
- func (tdp *TestDataProvider) Get(key string) interface{}
- func (tdp *TestDataProvider) GetBool(key string) bool
- func (tdp *TestDataProvider) GetInt(key string) int
- func (tdp *TestDataProvider) GetString(key string) string
- func (tdp *TestDataProvider) Set(key string, value interface{})
- type TestEnvironment
- type TestFactory
- func (tf *TestFactory) CleanupDatabase()
- func (tf *TestFactory) CreatePermission(overrides ...map[string]interface{}) *TestPermission
- func (tf *TestFactory) CreatePost(userID uint, overrides ...map[string]interface{}) *TestPost
- func (tf *TestFactory) CreateRole(overrides ...map[string]interface{}) *TestRole
- func (tf *TestFactory) CreateUser(overrides ...map[string]interface{}) *TestUser
- type TestFile
- type TestHelper
- type TestLogger
- type TestPermission
- type TestPost
- type TestResponse
- func (tr *TestResponse) AssertContains(t *testing.T, expected string)
- func (tr *TestResponse) AssertHeader(t *testing.T, key, expected string)
- func (tr *TestResponse) AssertJSON(t *testing.T, expected interface{})
- func (tr *TestResponse) AssertStatus(t *testing.T, expected int)
- func (tr *TestResponse) GetJSON(t *testing.T, target interface{})
- type TestRole
- type TestTimeout
- type TestUser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestApp ¶
TestApp represents a test application instance
func NewTestApp ¶
func NewTestApp(t *testing.T, config *TestConfig) *TestApp
NewTestApp creates a new test application
func (*TestApp) Close ¶
func (ta *TestApp) Close()
Close closes the test app and cleans up resources
func (*TestApp) Get ¶
func (ta *TestApp) Get(t *testing.T, path string) *TestResponse
Get performs a GET request
func (*TestApp) Post ¶
func (ta *TestApp) Post(t *testing.T, path string, body interface{}, headers map[string]string) *TestResponse
Post performs a POST request
type TestAssertion ¶
type TestAssertion struct {
// contains filtered or unexported fields
}
TestAssertion provides custom assertion utilities
func NewTestAssertion ¶
func NewTestAssertion(t *testing.T) *TestAssertion
NewTestAssertion creates a new test assertion
func (*TestAssertion) AssertEmpty ¶
func (ta *TestAssertion) AssertEmpty(value interface{}, msg ...string)
AssertEmpty asserts that a value is empty
func (*TestAssertion) AssertError ¶
func (ta *TestAssertion) AssertError(err error, msg ...string)
AssertError asserts that there is an error
func (*TestAssertion) AssertNoError ¶
func (ta *TestAssertion) AssertNoError(err error, msg ...string)
AssertNoError asserts that there is no error
func (*TestAssertion) AssertNotEmpty ¶
func (ta *TestAssertion) AssertNotEmpty(value interface{}, msg ...string)
AssertNotEmpty asserts that a value is not empty
type TestConfig ¶
TestConfig holds test configuration
func DefaultTestConfig ¶
func DefaultTestConfig() *TestConfig
DefaultTestConfig returns default test configuration
type TestDataProvider ¶
type TestDataProvider struct {
Data map[string]interface{}
}
TestDataProvider provides test data utilities
func NewTestDataProvider ¶
func NewTestDataProvider() *TestDataProvider
NewTestDataProvider creates a new test data provider
func (*TestDataProvider) Get ¶
func (tdp *TestDataProvider) Get(key string) interface{}
Get gets a test data value
func (*TestDataProvider) GetBool ¶
func (tdp *TestDataProvider) GetBool(key string) bool
GetBool gets a test data value as bool
func (*TestDataProvider) GetInt ¶
func (tdp *TestDataProvider) GetInt(key string) int
GetInt gets a test data value as int
func (*TestDataProvider) GetString ¶
func (tdp *TestDataProvider) GetString(key string) string
GetString gets a test data value as string
func (*TestDataProvider) Set ¶
func (tdp *TestDataProvider) Set(key string, value interface{})
Set sets a test data value
type TestEnvironment ¶
TestEnvironment represents a test environment
func NewTestEnvironment ¶
func NewTestEnvironment(t *testing.T) *TestEnvironment
NewTestEnvironment creates a new test environment
func (*TestEnvironment) AddFile ¶
func (te *TestEnvironment) AddFile(t *testing.T, name, content string) *TestFile
AddFile adds a file to the test environment
func (*TestEnvironment) Cleanup ¶
func (te *TestEnvironment) Cleanup(t *testing.T)
Cleanup cleans up the test environment
func (*TestEnvironment) GetPath ¶
func (te *TestEnvironment) GetPath(name string) string
GetPath returns the full path for a file in the test environment
type TestFactory ¶
TestFactory provides factory methods for creating test data
func NewTestFactory ¶
func NewTestFactory(db *gorm.DB) *TestFactory
NewTestFactory creates a new test factory
func (*TestFactory) CleanupDatabase ¶
func (tf *TestFactory) CleanupDatabase()
CleanupDatabase cleans up test database
func (*TestFactory) CreatePermission ¶
func (tf *TestFactory) CreatePermission(overrides ...map[string]interface{}) *TestPermission
CreatePermission creates a test permission
func (*TestFactory) CreatePost ¶
func (tf *TestFactory) CreatePost(userID uint, overrides ...map[string]interface{}) *TestPost
CreatePost creates a test post
func (*TestFactory) CreateRole ¶
func (tf *TestFactory) CreateRole(overrides ...map[string]interface{}) *TestRole
CreateRole creates a test role
func (*TestFactory) CreateUser ¶
func (tf *TestFactory) CreateUser(overrides ...map[string]interface{}) *TestUser
CreateUser creates a test user
type TestFile ¶
TestFile represents a test file
func CreateTestFile ¶
CreateTestFile creates a test file
type TestHelper ¶
type TestHelper struct {
App *fiber.App
DB *gorm.DB
Factory *TestFactory
}
TestHelper provides common test utilities
func NewTestHelper ¶
func NewTestHelper(t *testing.T) *TestHelper
NewTestHelper creates a new test helper
func (*TestHelper) Request ¶
func (th *TestHelper) Request(t *testing.T, method, path string, body interface{}, headers map[string]string) *TestResponse
Request performs an HTTP request using the Fiber app
func (*TestHelper) SetupTestRoutes ¶
func (th *TestHelper) SetupTestRoutes()
SetupTestRoutes sets up common test routes
type TestLogger ¶
type TestLogger struct {
Messages []string
}
TestLogger provides test logging utilities
func (*TestLogger) AssertLogged ¶
func (tl *TestLogger) AssertLogged(t *testing.T, expected string)
AssertLogged asserts that a message was logged
func (*TestLogger) GetMessages ¶
func (tl *TestLogger) GetMessages() []string
GetMessages returns all logged messages
type TestPermission ¶
type TestPermission struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"uniqueIndex"`
Description string `json:"description"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TestPermission represents a test permission model
type TestPost ¶
type TestPost struct {
ID uint `json:"id" gorm:"primaryKey"`
Title string `json:"title"`
Content string `json:"content"`
UserID uint `json:"user_id"`
User TestUser `json:"user" gorm:"foreignKey:UserID"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TestPost represents a test post model
type TestResponse ¶
TestResponse represents an HTTP test response
func (*TestResponse) AssertContains ¶
func (tr *TestResponse) AssertContains(t *testing.T, expected string)
AssertContains asserts the response body contains a substring
func (*TestResponse) AssertHeader ¶
func (tr *TestResponse) AssertHeader(t *testing.T, key, expected string)
AssertHeader asserts a response header value
func (*TestResponse) AssertJSON ¶
func (tr *TestResponse) AssertJSON(t *testing.T, expected interface{})
AssertJSON asserts the response body matches expected JSON
func (*TestResponse) AssertStatus ¶
func (tr *TestResponse) AssertStatus(t *testing.T, expected int)
AssertStatus asserts the response status code
func (*TestResponse) GetJSON ¶
func (tr *TestResponse) GetJSON(t *testing.T, target interface{})
GetJSON unmarshals the response body into the target
type TestRole ¶
type TestRole struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"uniqueIndex"`
Description string `json:"description"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}
TestRole represents a test role model
type TestTimeout ¶
TestTimeout provides timeout utilities for tests
func NewTestTimeout ¶
func NewTestTimeout(duration time.Duration) *TestTimeout
NewTestTimeout creates a new test timeout
func (*TestTimeout) WithTimeout ¶
func (tt *TestTimeout) WithTimeout(t *testing.T, fn func())
WithTimeout runs a function with a timeout