mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-26 19:37: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.
29 lines
838 B
Go
29 lines
838 B
Go
//go:build testing
|
|
|
|
package systems
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/henrygd/beszel/internal/entities/system"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCreateRecordsWiFiDisconnectReconnect(t *testing.T) {
|
|
sys, app := newTestSystemWithHub(t)
|
|
signal := -50.0
|
|
for _, snapshot := range []map[string]system.WiFi{
|
|
{"wlan0": {SSID: "home", Signal: &signal}, "wlan1": {SSID: "other"}},
|
|
{}, nil,
|
|
{"wlan0": {SSID: "new", Signal: &signal}},
|
|
} {
|
|
_, err := sys.createRecords(&system.CombinedData{Info: system.Info{WiFi: snapshot}})
|
|
require.NoError(t, err)
|
|
record, err := app.FindRecordById("systems", sys.Id)
|
|
require.NoError(t, err)
|
|
var info system.Info
|
|
require.NoError(t, record.UnmarshalJSONField("info", &info))
|
|
require.Len(t, info.WiFi, len(snapshot), "current info must replace previous connection state")
|
|
}
|
|
}
|