integration

package
v0.0.0-...-ea880c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

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

func CleanupTestData

func CleanupTestData(t *testing.T, db *mysql.Database)

CleanupTestData removes all test data from the database

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL