Documentation
¶
Index ¶
- func AssertErrorResponse(t *testing.T, w *httptest.ResponseRecorder, expectedStatus int, ...)
- func AssertJSONResponse(t *testing.T, w *httptest.ResponseRecorder, expectedStatus int, ...)
- func CleanupTestData(t *testing.T, db *mysql.Database)
- type TestServer
- func (ts *TestServer) Cleanup(t *testing.T)
- func (ts *TestServer) LoginTestUser(t *testing.T, email, password string) string
- func (ts *TestServer) MakeAuthenticatedRequest(method, path string, body interface{}, accessToken string) *httptest.ResponseRecorder
- func (ts *TestServer) MakeRequest(method, path string, body interface{}, headers map[string]string) *httptest.ResponseRecorder
- func (ts *TestServer) RegisterAndLoginTestUser(t *testing.T, email, password string) string
- func (ts *TestServer) RegisterTestUser(t *testing.T, email, password string) map[string]interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertErrorResponse ¶
func AssertErrorResponse(t *testing.T, w *httptest.ResponseRecorder, expectedStatus int, expectedError string)
AssertErrorResponse asserts the response is an error with expected message
func AssertJSONResponse ¶
func AssertJSONResponse(t *testing.T, w *httptest.ResponseRecorder, expectedStatus int, expectedFields map[string]interface{})
AssertJSONResponse asserts the JSON response matches expected values
Types ¶
type TestServer ¶
type TestServer struct {
Router *gin.Engine
DB *mysql.Database
TokenService *token.TokenService
UserRepo repository.UserRepository
SessionRepo repository.SessionRepository
RefreshTokenRepo repository.RefreshTokenRepository
UserOAuthRepo repository.UserOAuthRepository
UserProfileRepo repository.UserProfileRepository
RBACService *rbac.RBACService
Config *config.Config
}
TestServer holds the test environment
func SetupTestServer ¶
func SetupTestServer(t *testing.T) *TestServer
SetupTestServer initializes a test server with all dependencies
func (*TestServer) Cleanup ¶
func (ts *TestServer) Cleanup(t *testing.T)
Cleanup closes the database connection and cleans up test data
func (*TestServer) LoginTestUser ¶
func (ts *TestServer) LoginTestUser(t *testing.T, email, password string) string
LoginTestUser logs in a test user and returns access token
func (*TestServer) MakeAuthenticatedRequest ¶
func (ts *TestServer) MakeAuthenticatedRequest(method, path string, body interface{}, accessToken string) *httptest.ResponseRecorder
MakeAuthenticatedRequest makes an authenticated HTTP request
func (*TestServer) MakeRequest ¶
func (ts *TestServer) MakeRequest(method, path string, body interface{}, headers map[string]string) *httptest.ResponseRecorder
MakeRequest makes an HTTP request to the test server
func (*TestServer) RegisterAndLoginTestUser ¶
func (ts *TestServer) RegisterAndLoginTestUser(t *testing.T, email, password string) string
RegisterAndLoginTestUser is a helper that registers and logs in a user
func (*TestServer) RegisterTestUser ¶
func (ts *TestServer) RegisterTestUser(t *testing.T, email, password string) map[string]interface{}
RegisterTestUser registers a test user and returns the response
Click to show internal directories.
Click to hide internal directories.