Add API Integration Tests for Core Endpoints #1

Open
opened 2025-07-01 14:45:54 +12:00 by guisea · 0 comments
Owner

Overview

The application currently has excellent unit test coverage with mocked dependencies, but is completely missing integration tests for API endpoints. This leaves significant gaps in verifying real-world HTTP request/response functionality.

Current State

  • Comprehensive unit tests with mocked datastores
  • No API/HTTP handler integration tests
  • No authentication/session testing
  • No middleware testing

Required Integration Tests

High Priority Endpoints

  • POST /api/v1/transactions - Transaction creation with real database
  • GET /api/v1/transactions - Transaction listing and filtering
  • POST /api/v1/accounts - Account creation
  • GET /api/v1/accounts - Account listing with balances
  • PUT /api/v1/accounts/{id} - Account updates
  • DELETE /api/v1/accounts/{id} - Account deletion
  • POST /api/v1/auth - Authentication flow
  • POST /api/v1/orgs - Organization creation

Medium Priority Endpoints

  • GET /api/v1/prices - Price/currency operations
  • POST /api/v1/budget - Budget creation and management
  • GET /api/v1/users - User management
  • API Key authentication endpoints

Implementation Notes

  • Use the pattern established in core/api/attachment_integration_test.go as a template
  • Tests should use real SQLite database with proper setup/teardown
  • Include both success and error cases
  • Verify HTTP status codes, response bodies, and database state
  • Test authentication and authorization flows

Acceptance Criteria

  • All core endpoints have integration tests
  • Tests verify both HTTP responses and database persistence
  • Tests include authentication/authorization scenarios
  • Tests run in CI/CD pipeline
  • Test coverage report shows integration test coverage
## Overview The application currently has excellent unit test coverage with mocked dependencies, but is completely missing integration tests for API endpoints. This leaves significant gaps in verifying real-world HTTP request/response functionality. ## Current State - ✅ Comprehensive unit tests with mocked datastores - ❌ No API/HTTP handler integration tests - ❌ No authentication/session testing - ❌ No middleware testing ## Required Integration Tests ### High Priority Endpoints - [ ] `POST /api/v1/transactions` - Transaction creation with real database - [ ] `GET /api/v1/transactions` - Transaction listing and filtering - [ ] `POST /api/v1/accounts` - Account creation - [ ] `GET /api/v1/accounts` - Account listing with balances - [ ] `PUT /api/v1/accounts/{id}` - Account updates - [ ] `DELETE /api/v1/accounts/{id}` - Account deletion - [ ] `POST /api/v1/auth` - Authentication flow - [ ] `POST /api/v1/orgs` - Organization creation ### Medium Priority Endpoints - [ ] `GET /api/v1/prices` - Price/currency operations - [ ] `POST /api/v1/budget` - Budget creation and management - [ ] `GET /api/v1/users` - User management - [ ] API Key authentication endpoints ## Implementation Notes - Use the pattern established in `core/api/attachment_integration_test.go` as a template - Tests should use real SQLite database with proper setup/teardown - Include both success and error cases - Verify HTTP status codes, response bodies, and database state - Test authentication and authorization flows ## Acceptance Criteria - [ ] All core endpoints have integration tests - [ ] Tests verify both HTTP responses and database persistence - [ ] Tests include authentication/authorization scenarios - [ ] Tests run in CI/CD pipeline - [ ] Test coverage report shows integration test coverage
guisea added the enhancement label 2025-07-01 14:47:13 +12:00
guisea self-assigned this 2025-07-01 14:49:16 +12:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: guisea/openaccounting-server#1