Files
rtnetmon/internal/starlink/starlink_test.go
T
clawbot 769511dec2
check / check (push) Failing after 4s
Add Starlink status lines for the physical gateway pane (closes #3) (#7)
Detection is a TCP connect to the dish endpoint bound to the physical
interface; once a dish answers, get_status is read every 5s and two
status lines render under the physical pane, red on disconnect or
alert. No dish: nothing drawn, no RPC. Minimal vendored proto bindings
for get_status only. Independent review passed (PR 7 comment 100012).

Model: opus-4-8 (implementation and review); model: claude-fable-5
(merge)
2026-09-22 20:56:01 +02:00

80 lines
1.8 KiB
Go

package starlink_test
import (
"testing"
"time"
"git.eeqj.de/sneak/rtnetmon/internal/starlink"
)
func TestRender(t *testing.T) {
t.Parallel()
connected := starlink.Status{
State: "CONNECTED",
Uptime: 3*24*time.Hour + 4*time.Hour + 12*time.Minute,
ObstructionPct: 0.1,
Alerts: 0,
PopPingMs: 34,
PopPingDropPct: 0.0,
DownlinkMbps: 145.3,
UplinkMbps: 12.1,
}
tests := []struct {
name string
status starlink.Status
wantLine1 string
wantLine2 string
wantAlert bool
}{
{
name: "connected, no alert",
status: connected,
wantLine1: "Starlink: CONNECTED uptime 3d 4h 12m obstruction 0.1% alerts 0",
wantLine2: " pop ping 34ms / drop 0.0% down 145.3Mbps / up 12.1Mbps",
wantAlert: false,
},
{
name: "searching is an alert",
status: starlink.Status{
State: "SEARCHING",
Uptime: 0,
},
wantLine1: "Starlink: SEARCHING uptime 0d 0h 0m obstruction 0.0% alerts 0",
wantLine2: " pop ping 0ms / drop 0.0% down 0.0Mbps / up 0.0Mbps",
wantAlert: true,
},
{
name: "connected but alerts active",
status: starlink.Status{
State: "CONNECTED",
Uptime: 90 * time.Minute,
Alerts: 2,
},
wantLine1: "Starlink: CONNECTED uptime 0d 1h 30m obstruction 0.0% alerts 2",
wantLine2: " pop ping 0ms / drop 0.0% down 0.0Mbps / up 0.0Mbps",
wantAlert: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
line1, line2, alert := starlink.Render(tt.status)
if line1 != tt.wantLine1 {
t.Errorf("line1 = %q, want %q", line1, tt.wantLine1)
}
if line2 != tt.wantLine2 {
t.Errorf("line2 = %q, want %q", line2, tt.wantLine2)
}
if alert != tt.wantAlert {
t.Errorf("alert = %v, want %v", alert, tt.wantAlert)
}
})
}
}