unarr/internal/funnel/funnel_test.go
Deivid Soto 75e191f86b fix(docker): three streaming/reliability bugs found in live docker test
funnel: urlPattern matched api.trycloudflare.com before the real quick-tunnel
URL. Cloudflared logs the control-plane endpoint early, so the agent was
advertising a dead URL. Tighten regex to require at least one hyphen — quick
tunnels are always multi-word (e.g. make-appointments-negotiation-blacks).
Covers with funnel_test.go regression test.

download(oneshot): progress reporter called /api/internal/agent/status with a
synthetic "oneshot-<hash>" task ID that is not a UUID, causing the server to
return 400 every 5 s for the entire download. Pass nil client to
NewProgressReporter for one-shot mode; flush/ReportFinal are no-ops when
reporter == nil so terminal output continues unchanged.

torrent: piece-completion SQLite DB (anacrolix) was created inside the download
dir (DataDir). On NFS/SMB mounts SQLite file locking times out, emitting a
warning and falling back to an ephemeral in-memory DB. Add PieceCompletionDir
to TorrentConfig; the daemon now passes config.DataDir() (agent state dir,
always local) so the DB stays off the network mount. One-shot download leaves
the field empty → harmless in-memory fallback as before.
2026-05-30 08:59:33 +02:00

40 lines
1,020 B
Go

package funnel
import "testing"
func TestURLPattern(t *testing.T) {
cases := []struct {
name string
line string
want string
}{
{
name: "real quick tunnel banner",
line: "2026-05-29T22:18:33Z INF | https://make-appointments-negotiation-blacks.trycloudflare.com |",
want: "https://make-appointments-negotiation-blacks.trycloudflare.com",
},
{
name: "two-word hostname",
line: "https://blue-river.trycloudflare.com is ready",
want: "https://blue-river.trycloudflare.com",
},
{
name: "control-plane api endpoint is ignored",
line: `2026-05-29T22:17:59Z DBG POST https://api.trycloudflare.com/tunnel`,
want: "",
},
{
name: "no trycloudflare url",
line: "2026-05-29T22:17:44Z INF Requesting new quick Tunnel on trycloudflare.com...",
want: "",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if got := urlPattern.FindString(tc.line); got != tc.want {
t.Fatalf("FindString(%q) = %q, want %q", tc.line, got, tc.want)
}
})
}
}