Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

56 lignes
1.6KB

  1. package main
  2. import (
  3. "testing"
  4. apppkg "github.com/jan/fm-rds-tx/internal/app"
  5. cfgpkg "github.com/jan/fm-rds-tx/internal/config"
  6. "github.com/jan/fm-rds-tx/internal/output"
  7. "github.com/jan/fm-rds-tx/internal/platform"
  8. )
  9. func TestTxBridgeExportsQueueStats(t *testing.T) {
  10. cfg := cfgpkg.Default()
  11. driver := platform.NewSimulatedDriver(nil)
  12. engine := apppkg.NewEngine(cfg, driver)
  13. bridge := &txBridge{engine: engine}
  14. stats := bridge.TXStats()
  15. raw, ok := stats["queue"]
  16. if !ok {
  17. t.Fatalf("expected queue stats in tx stats")
  18. }
  19. queue, ok := raw.(output.QueueStats)
  20. if !ok {
  21. t.Fatalf("queue stats type mismatch: %T", raw)
  22. }
  23. if queue.Capacity != cfg.Runtime.FrameQueueCapacity {
  24. t.Fatalf("unexpected queue capacity: want %d got %d", cfg.Runtime.FrameQueueCapacity, queue.Capacity)
  25. }
  26. if queue.Health != output.QueueHealthCritical {
  27. t.Fatalf("queue health should be critical with empty queue, got %s", queue.Health)
  28. }
  29. indicatorRaw, ok := stats["runtimeIndicator"]
  30. if !ok {
  31. t.Fatalf("expected runtimeIndicator in tx stats")
  32. }
  33. indicator, ok := indicatorRaw.(apppkg.RuntimeIndicator)
  34. if !ok {
  35. t.Fatalf("runtimeIndicator type mismatch: %T", indicatorRaw)
  36. }
  37. if indicator != apppkg.RuntimeIndicatorQueueCritical {
  38. t.Fatalf("runtime indicator should be queueCritical, got %s", indicator)
  39. }
  40. if historyRaw, ok := stats["faultHistory"]; !ok {
  41. t.Fatalf("expected faultHistory in tx stats")
  42. } else if history, ok := historyRaw.([]apppkg.FaultEvent); !ok {
  43. t.Fatalf("faultHistory type mismatch: %T", historyRaw)
  44. } else if len(history) != 0 {
  45. t.Fatalf("expected no faults yet, got %d", len(history))
  46. }
  47. }