mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-28 19:41:17 +00:00
- Fix deadlock and race conditions in internal/alerts - Add comprehensive error path tests for internal/config - Fix 401 handling in internal/api - Fix Docker Swarm task filtering test logic
32 lines
805 B
Go
32 lines
805 B
Go
package config
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGuestMetadataStore_SaveErrors(t *testing.T) {
|
|
tempDir := t.TempDir()
|
|
|
|
mfs := &mockFSError{FileSystem: defaultFileSystem{}, mkdirError: errors.New("mkdir error")}
|
|
store := NewGuestMetadataStore(tempDir, mfs)
|
|
|
|
// Trigger save via Set
|
|
err := store.Set("id1", &GuestMetadata{LastKnownName: "test"})
|
|
assert.Error(t, err)
|
|
assert.Contains(t, err.Error(), "failed to create data directory")
|
|
}
|
|
|
|
func TestGuestMetadataStore_LoadErrors(t *testing.T) {
|
|
tempDir := t.TempDir()
|
|
|
|
mfs := &mockFSError{FileSystem: defaultFileSystem{}}
|
|
store := NewGuestMetadataStore(tempDir, mfs)
|
|
|
|
mfs.readError = errors.New("read error")
|
|
err := store.Load()
|
|
assert.Error(t, err)
|
|
assert.Contains(t, err.Error(), "read error")
|
|
}
|