Add homelab service and system health monitoring

This commit is contained in:
Maxim
2026-08-01 12:02:09 +03:00
parent ad8972320d
commit 980f69cf8f
11 changed files with 674 additions and 33 deletions

29
services_test.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import "testing"
func TestServiceCRUD(t *testing.T) {
store, err := openStore(":memory:")
if err != nil {
t.Fatal(err)
}
defer store.Close()
v, err := store.SaveService(MonitoredService{Name: "Test", URL: "https://example.test", CheckType: "http", ExpectedCode: 204, TimeoutSeconds: 2, Enabled: true})
if err != nil || v.ID == 0 {
t.Fatalf("save: %+v %v", v, err)
}
items, err := store.Services()
if err != nil || len(items) != 1 {
t.Fatalf("list: %+v %v", items, err)
}
if err := store.DeleteService(v.ID); err != nil {
t.Fatal(err)
}
}
func TestValidateServiceAllowsLocalAddress(t *testing.T) {
v := MonitoredService{Name: "Host", LocalAddress: "192.168.0.12", CheckType: "ping", TimeoutSeconds: 5}
if err := validateService(v); err != nil {
t.Fatal(err)
}
}