mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-30 05:17:49 +02:00
feat: monitor connected Wi-Fi signal per interface (#2367)
This commit is contained in:
28
internal/hub/systems/system_wifi_test.go
Normal file
28
internal/hub/systems/system_wifi_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
//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}, Stats: system.Stats{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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user