switch to iterators and client polling
Publish / release (push) Failing after 17m20s

This commit is contained in:
2026-06-22 22:20:32 -04:00
parent 24fe4258f7
commit f174c2922c
7 changed files with 154 additions and 143 deletions
+12 -12
View File
@@ -144,21 +144,21 @@ func TestClientWingbitsEndpoints(t *testing.T) {
}
}
func TestStreamAircraft(t *testing.T) {
func TestPollAircraft(t *testing.T) {
c := newTestClient(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
ch := c.StreamAircraft(ctx, time.Hour)
select {
case u := <-ch:
if u.Err != nil || u.Value == nil || len(u.Value.Aircraft) == 0 {
t.Fatalf("first update bad: %v", u.Err)
// A long interval means the iterator only yields its immediate first sample;
// breaking out must stop polling cleanly (no goroutine, no hang).
var got int
for report, err := range c.PollAircraft(ctx, time.Hour, readsb.WithPosition()) {
if err != nil || report == nil || len(report.Aircraft) == 0 {
t.Fatalf("first poll bad: %v", err)
}
case <-time.After(5 * time.Second):
t.Fatal("no first update")
got++
break
}
cancel()
for range ch { // channel must drain and close after cancellation
if got != 1 {
t.Fatalf("expected exactly one sample before break, got %d", got)
}
}