unarr/internal/cmd/daemon_test.go
Deivid Soto 5d4a67c7a2 feat(sync): replace WS+DO transport with unified HTTP sync
Replace the WebSocket + Cloudflare Durable Object architecture with a
single POST /sync endpoint. The CLI now operates autonomously with local
state (tasks.json) and syncs bidirectionally via adaptive-interval HTTP
polling (3s watching, 60s idle).

- Remove transport_ws, transport_hybrid, transport_http (~2,600 lines)
- Add SyncClient with adaptive interval loop
- Add LocalState for CLI-side task persistence
- Add TaskStateFromUpdate() helper (DRY)
- Extract finalize() to deduplicate processTask/processTaskRetry
- Consolidate shortID() into agent.ShortID (was in 3 packages)
- Wire GetActiveCount so `unarr status` shows active tasks
- Remove poll_interval, heartbeat_interval, ws_url from config
- Simplify ProgressReporter (sync replaces direct HTTP reporting)
2026-04-08 18:50:59 +02:00

29 lines
541 B
Go

package cmd
import "testing"
func TestFormatSpeedLog(t *testing.T) {
tests := []struct {
bps int64
want string
}{
{0, "0 B/s"},
{500, "500 B/s"},
{1023, "1023 B/s"},
{1024, "1 KB/s"},
{10240, "10 KB/s"},
{1048576, "1.0 MB/s"},
{5242880, "5.0 MB/s"},
{1073741824, "1.0 GB/s"},
{2147483648, "2.0 GB/s"},
}
for _, tt := range tests {
t.Run(tt.want, func(t *testing.T) {
got := formatSpeedLog(tt.bps)
if got != tt.want {
t.Errorf("formatSpeedLog(%d) = %q, want %q", tt.bps, got, tt.want)
}
})
}
}