mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-26 11:27:47 +02:00
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.
26 lines
612 B
Go
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")
|
|
}
|
|
}
|