mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 07:29:14 +01:00
split the integration harness into server, api and util modules
tools/integration-test.nu is now just the entrypoint. The server lifecycle and fixture preparation live in tools/integration/servers.nu, the Subsonic request helpers in subsonic.nu, and shared waiting/port helpers in util.nu. No behaviour change; the assertions still live in the Kotlin tests.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
# Shared helpers for the integration harness: waiting and port checks.
|
||||
|
||||
export def poll [label: string, check: closure, --attempts (-n): int = 120] {
|
||||
for attempt in 0..<$attempts {
|
||||
let value = (try { do $check } catch { null })
|
||||
if $value != null { return $value }
|
||||
if $attempt > 0 and ($attempt mod 5) == 0 { print $"waiting for ($label)..." }
|
||||
sleep 1sec
|
||||
}
|
||||
error make { msg: $"timed out waiting for ($label)" }
|
||||
}
|
||||
|
||||
export def port-in-use [port: int] {
|
||||
(^curl -s -o /dev/null --max-time 1 $"http://127.0.0.1:($port)/" | complete).exit_code != 7
|
||||
}
|
||||
Reference in New Issue
Block a user