Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
package config
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestLoadAlertConfig_ReadError(t *testing.T) {
if os.Getuid() == 0 {
t.Skip("Skipping as root")
}
tempDir := t.TempDir()
cp := NewConfigPersistence(tempDir)
// Create unreadable alerts.json
path := filepath.Join(tempDir, "alerts.json")
require.NoError(t, os.WriteFile(path, []byte("{}"), 0000))
cfg, err := cp.LoadAlertConfig()
assert.Error(t, err)
assert.Nil(t, cfg)
}
func TestLoadAlertConfig_UnmarshalError(t *testing.T) {
tempDir := t.TempDir()
cp := NewConfigPersistence(tempDir)
path := filepath.Join(tempDir, "alerts.json")
require.NoError(t, os.WriteFile(path, []byte("{invalid"), 0644))
cfg, err := cp.LoadAlertConfig()
assert.Error(t, err)
assert.Nil(t, cfg)
}