Documentation
¶
Index ¶
- func AssertJSONResponse(t *testing.T, rr *httptest.ResponseRecorder, expectedStatus int, ...)
- func CleanupTestEnv(t *testing.T)
- func CleanupTestUsers(t *testing.T)
- func CreateTestArticle(t *testing.T, db database.Database, feedID int, title, url string) *database.Article
- func CreateTestDB(t *testing.T) database.Database
- func CreateTestDatastoreDB(t *testing.T) database.Database
- func CreateTestFeed(t *testing.T, db database.Database, title, url, description string) *database.Feed
- func CreateTestUser(t *testing.T, db database.Database, googleID, email, name string) *database.User
- func CreateUnauthenticatedRequest(t *testing.T, method, url string, body interface{}) *http.Request
- func NewMockFeedServer(t *testing.T, feedXML string) *httptest.Server
- func NewMockFeedServerWithStatus(t *testing.T, statusCode int, body string) *httptest.Server
- func NewMockMultiFeedServer(t *testing.T, feeds map[string]string) *httptest.Server
- func SetupTestEnv(t *testing.T)
- type MockHTTPClient
- type TestServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertJSONResponse ¶
func AssertJSONResponse(t *testing.T, rr *httptest.ResponseRecorder, expectedStatus int, expectedBody interface{})
AssertJSONResponse asserts that the response has the expected status code and JSON body
func CleanupTestEnv ¶
CleanupTestEnv cleans up test environment variables
func CleanupTestUsers ¶
CleanupTestUsers removes all test users from the main database This should be called at the start and end of integration tests to ensure clean state
func CreateTestArticle ¶
func CreateTestArticle(t *testing.T, db database.Database, feedID int, title, url string) *database.Article
CreateTestArticle creates a test article in the database
func CreateTestDB ¶
CreateTestDB creates an in-memory SQLite database for testing
func CreateTestDatastoreDB ¶
CreateTestDatastoreDB creates a Datastore database for testing This requires the Datastore emulator to be running
func CreateTestFeed ¶
func CreateTestFeed(t *testing.T, db database.Database, title, url, description string) *database.Feed
CreateTestFeed creates a test feed in the database
func CreateTestUser ¶
func CreateTestUser(t *testing.T, db database.Database, googleID, email, name string) *database.User
CreateTestUser creates a test user in the database
func CreateUnauthenticatedRequest ¶
CreateUnauthenticatedRequest creates an HTTP request without authentication
func NewMockFeedServer ¶
NewMockFeedServer creates a mock HTTP server that serves RSS/Atom feed content Returns the server and its URL. The caller must call server.Close() when done.
func NewMockFeedServerWithStatus ¶
NewMockFeedServerWithStatus creates a mock HTTP server that returns a specific status code
func NewMockMultiFeedServer ¶
NewMockMultiFeedServer creates a mock HTTP server that can serve different feeds based on the path
func SetupTestEnv ¶
SetupTestEnv sets up environment variables for testing
Types ¶
type MockHTTPClient ¶
MockHTTPClient wraps an httptest.Server to provide an HTTP client that redirects all requests to the mock server
func NewMockHTTPClient ¶
func NewMockHTTPClient(server *httptest.Server) *MockHTTPClient
NewMockHTTPClient creates a mock HTTP client from an httptest.Server
type TestServer ¶
type TestServer struct {
Router *gin.Engine
AuthService *auth.AuthService
SessionManager *auth.SessionManager
CSRFManager *auth.CSRFManager
FeedHandler *handlers.FeedHandler
AuthHandler *handlers.AuthHandler
DB database.Database
}
TestServer wraps the test server with authentication helpers
func SetupTestServer ¶
func SetupTestServer(t *testing.T) *TestServer
SetupTestServer creates a test server with all dependencies
func (*TestServer) CreateAuthenticatedRequest ¶
func (ts *TestServer) CreateAuthenticatedRequest(t *testing.T, method, url string, body interface{}, user *database.User) *http.Request
CreateAuthenticatedRequest creates an HTTP request with authentication and CSRF token
func (*TestServer) ExecuteRequest ¶
func (ts *TestServer) ExecuteRequest(req *http.Request) *httptest.ResponseRecorder
ExecuteRequest executes an HTTP request and returns the response