Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

66 líneas
1.6KB

  1. package app
  2. import (
  3. "testing"
  4. "github.com/jan/fm-rds-tx/internal/output"
  5. )
  6. func TestRuntimeIndicatorAndAlert(t *testing.T) {
  7. cases := []struct {
  8. name string
  9. health output.QueueHealth
  10. recentLate bool
  11. wantIndicator RuntimeIndicator
  12. wantAlert string
  13. }{
  14. {
  15. name: "queue critical",
  16. health: output.QueueHealthCritical,
  17. wantIndicator: RuntimeIndicatorQueueCritical,
  18. wantAlert: "queue health critical",
  19. },
  20. {
  21. name: "queue low",
  22. health: output.QueueHealthLow,
  23. wantIndicator: RuntimeIndicatorDegraded,
  24. wantAlert: "queue health low",
  25. },
  26. {
  27. name: "late buffers",
  28. health: output.QueueHealthNormal,
  29. recentLate: true,
  30. wantIndicator: RuntimeIndicatorDegraded,
  31. wantAlert: "late buffers",
  32. },
  33. {
  34. name: "late buffers override queue low",
  35. health: output.QueueHealthLow,
  36. recentLate: true,
  37. wantIndicator: RuntimeIndicatorDegraded,
  38. wantAlert: "late buffers",
  39. },
  40. {
  41. name: "normal",
  42. health: output.QueueHealthNormal,
  43. wantIndicator: RuntimeIndicatorNormal,
  44. wantAlert: "",
  45. },
  46. }
  47. for _, tc := range cases {
  48. tc := tc
  49. t.Run(tc.name, func(t *testing.T) {
  50. t.Parallel()
  51. got := runtimeIndicator(tc.health, tc.recentLate)
  52. if got != tc.wantIndicator {
  53. t.Fatalf("indicator: expected %s, got %s", tc.wantIndicator, got)
  54. }
  55. alert := runtimeAlert(tc.health, tc.recentLate)
  56. if alert != tc.wantAlert {
  57. t.Fatalf("alert: expected %q, got %q", tc.wantAlert, alert)
  58. }
  59. })
  60. }
  61. }