Files
epage-go/TESTING.md
Luke Tainton 8bd45193b0 Add initial implementation of ePage application with Docker support
- Create main application logic with HTTP handlers for form submissions
- Implement Pushover API integration for sending messages
- Add unit tests for handlers and Pushover payload structure
- Include Dockerfile and docker-compose configuration for easy deployment
- Add example environment file and update README with setup instructions
- Create HTML templates for user interface
2026-04-18 20:02:32 +01:00

1.7 KiB

Unit Tests

This project includes comprehensive unit tests for the ePage application.

Test Coverage

  • 58.2% code coverage across the application

Test Files

send_page_test.go

Tests for the Pushover API integration:

  • TestPushoverPayloadStructure - Validates JSON payload structure and serialization
  • TestPushoverMessageFormat - Tests message formatting with various input types

handlers_test.go

Tests for HTTP handlers and template rendering:

  • TestHandleIndexGET - Tests GET / endpoint returns template
  • TestHandleSendPOST - Tests POST / with valid and invalid form data
  • TestHandleSendInvalidForm - Tests error handling for malformed requests
  • TestTemplateCache - Verifies template caching works correctly
  • TestLoadTemplateNotFound - Tests handling of missing templates
  • TestLoadTemplateInvalidTemplate - Tests handling of invalid template syntax
  • TestServerIntegration - Integration test of full request/response cycle

Running Tests

Run all tests:

go test -v ./src

Run tests with coverage:

go test -v -cover ./src

Run a specific test:

go test -v -run TestHandleIndexGET ./src

Run tests with detailed coverage report:

go test -coverprofile=coverage.out ./src
go tool cover -html=coverage.out

Test Design

The tests focus on:

  • Handler logic: Form validation, routing, and response generation
  • Template handling: Caching, error handling, and rendering
  • Data structures: JSON serialization and message formatting
  • Integration: Full request/response cycles through the HTTP server

The tests use temporary directories and mock templates to avoid file system dependencies and can run in isolation.