Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

2.6 KiB

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)

go test ./tests/... -count=1

With verbose output

go test ./tests/... -v

Run specific package

go test ./tests/appcontext/ -v
go test ./tests/controller/ -v

E2E / Integration tests (requires Kafka)

E2E_TEST=1 go test ./tests/... -count=1

Short mode (skips integration tests)

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