mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-28 11:30:15 +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
34 lines
813 B
Go
34 lines
813 B
Go
package config
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestLoadEnvTokenSuppressions_Branches(t *testing.T) {
|
|
tempDir := t.TempDir()
|
|
cp := NewConfigPersistence(tempDir)
|
|
suppFile := filepath.Join(tempDir, "env_token_suppressions.json")
|
|
|
|
// 1. ReadFile error
|
|
mfs := &mockFSError{FileSystem: defaultFileSystem{}, readError: errors.New("read error")}
|
|
cp.SetFileSystem(mfs)
|
|
_, err := cp.LoadEnvTokenSuppressions()
|
|
assert.Error(t, err)
|
|
mfs.readError = nil
|
|
|
|
// 2. Empty data
|
|
os.WriteFile(suppFile, []byte(""), 0600)
|
|
hashes, err := cp.LoadEnvTokenSuppressions()
|
|
assert.NoError(t, err)
|
|
assert.Empty(t, hashes)
|
|
|
|
// 3. Unmarshal error
|
|
os.WriteFile(suppFile, []byte("not-json"), 0600)
|
|
_, err = cp.LoadEnvTokenSuppressions()
|
|
assert.Error(t, err)
|
|
}
|