Files
beszel-ipv6/internal/records/records_wifi_test.go
henrygd 16e3fbadce store compact RSSI stats and skip real-time collection
Stats.WiFi is now map[string]int8 (json "wf") holding only available
RSSI
readings; SSID and unavailable signals stay in Info.WiFi. Averages are
rounded to whole dBm.

Wi-Fi is collected only on the default 60s interval; real-time requests
reuse the last snapshot to avoid spawning osascript / dumping the BSS
cache every second.
2026-09-25 18:02:34 -04:00

26 lines
612 B
Go

package records
import (
"testing"
"github.com/henrygd/beszel/internal/entities/system"
)
func TestWiFiAverageAvailableSamples(t *testing.T) {
input := []system.Stats{
{WiFi: map[string]int8{"wlan0": -40}},
{},
{WiFi: map[string]int8{"wlan0": -61, "wlan1": -80}},
}
result := AverageSystemStatsSlice(input)
if len(result.WiFi) != 2 || result.WiFi["wlan0"] != -51 || result.WiFi["wlan1"] != -80 {
t.Fatalf("%#v", result.WiFi)
}
if input[0].WiFi["wlan0"] != -40 {
t.Fatal("mutated input")
}
if len(AverageSystemStatsSlice([]system.Stats{{}, {}}).WiFi) != 0 {
t.Fatal("invented wifi")
}
}