|
|
|
@@ -0,0 +1,36 @@ |
|
|
|
package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"testing" |
|
|
|
|
|
|
|
apppkg "github.com/jan/fm-rds-tx/internal/app" |
|
|
|
cfgpkg "github.com/jan/fm-rds-tx/internal/config" |
|
|
|
"github.com/jan/fm-rds-tx/internal/output" |
|
|
|
"github.com/jan/fm-rds-tx/internal/platform" |
|
|
|
) |
|
|
|
|
|
|
|
func TestTxBridgeExportsQueueStats(t *testing.T) { |
|
|
|
cfg := cfgpkg.Default() |
|
|
|
driver := platform.NewSimulatedDriver(nil) |
|
|
|
engine := apppkg.NewEngine(cfg, driver) |
|
|
|
bridge := &txBridge{engine: engine} |
|
|
|
stats := bridge.TXStats() |
|
|
|
|
|
|
|
raw, ok := stats["queue"] |
|
|
|
if !ok { |
|
|
|
t.Fatalf("expected queue stats in tx stats") |
|
|
|
} |
|
|
|
|
|
|
|
queue, ok := raw.(output.QueueStats) |
|
|
|
if !ok { |
|
|
|
t.Fatalf("queue stats type mismatch: %T", raw) |
|
|
|
} |
|
|
|
|
|
|
|
if queue.Capacity != cfg.Runtime.FrameQueueCapacity { |
|
|
|
t.Fatalf("unexpected queue capacity: want %d got %d", cfg.Runtime.FrameQueueCapacity, queue.Capacity) |
|
|
|
} |
|
|
|
|
|
|
|
if queue.Health != output.QueueHealthCritical { |
|
|
|
t.Fatalf("queue health should be critical with empty queue, got %s", queue.Health) |
|
|
|
} |
|
|
|
} |