- 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
1.7 KiB
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 serializationTestPushoverMessageFormat- Tests message formatting with various input types
handlers_test.go
Tests for HTTP handlers and template rendering:
TestHandleIndexGET- Tests GET / endpoint returns templateTestHandleSendPOST- Tests POST / with valid and invalid form dataTestHandleSendInvalidForm- Tests error handling for malformed requestsTestTemplateCache- Verifies template caching works correctlyTestLoadTemplateNotFound- Tests handling of missing templatesTestLoadTemplateInvalidTemplate- Tests handling of invalid template syntaxTestServerIntegration- 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.