# Test Suite Summary ## Overview This directory contains unit tests, integration tests, and end-to-end tests for the presence system. Tests are organized by package/component. ## Test Packages | Package | Type | Description | |---------|------|-------------| | `tests/appcontext` | Unit | AppState (beacon lookup, beacons, settings, beacon events) | | `tests/utils` | Unit | ParseADFast, RemoveFlagBytes, CalculateDistance, LoopADStructures | | `tests/kafkaclient` | Unit | KafkaManager (Init, Populate, GetReader/Writer) - requires E2E_TEST=1 | | `tests/model` | Unit | BeaconEvent (Hash, ToJSON), ParserRegistry, Config | | `tests/controller` | Unit | HTTP handlers (gateways, trackers, zones, settings) | | `tests/service` | Unit | SendParserConfig, LocationToBeaconService | | `tests/config` | Unit | Config constants, Load with env vars | | `tests/logger` | Unit | CreateLogger, cleanup | | `tests/location` | Unit | Location scoring formula, CalculateDistance | | `tests/bridge` | Unit + Integration | MQTT handler, event loop, Kafka integration | | `tests/decoder` | Unit + Integration | decodeBeacon, parser registry, event loop | | `tests/e2e` | E2E | Placeholder (skipped unless E2E_TEST=1) | ## Running Tests ### All unit tests (default, no Kafka required) ```bash go test ./tests/... -count=1 ``` ### With verbose output ```bash go test ./tests/... -v ``` ### Run specific package ```bash go test ./tests/appcontext/ -v go test ./tests/controller/ -v ``` ### E2E / Integration tests (requires Kafka) ```bash E2E_TEST=1 go test ./tests/... -count=1 ``` ### Short mode (skips integration tests) ```bash go test ./tests/... -short ``` ## Test Counts - **appcontext**: 9 tests (NewAppState, beacon lookup, beacons, events, settings, concurrency) - **utils**: 8 tests (ParseADFast, RemoveFlagBytes, CalculateDistance, LoopADStructures) - **kafkaclient**: 5 tests (skipped without E2E_TEST=1) - **model**: 6 tests (BeaconEvent, ParserRegistry, Config) - **controller**: 6 tests (gateway CRUD, tracker list, zone list, settings) - **service**: 3 tests (SendParserConfig, LocationToBeaconService) - **config**: 2 tests (constants, Load) - **logger**: 1 test (CreateLogger) - **location**: 2 tests (scoring formula, distance) - **bridge**: MQTT handler, event loop, integration (skipped without E2E_TEST=1) - **decoder**: decode tests, parser registry, event loop, integration (skipped without E2E_TEST=1) - **e2e**: 1 placeholder test (skipped) ## Dependencies - **gorm.io/driver/sqlite**: Used for in-memory DB in controller/service tests - **github.com/segmentio/kafka-go**: Kafka client (integration tests) - **github.com/gorilla/mux**: URL vars in controller tests