test(system-settings): update tests for scan_poll_interval_seconds

- Update validation to use scan_poll_interval_seconds field (1-3600 seconds)
- Update all test cases and assertions to use new field name
- Update integration test to reflect new field name
This commit is contained in:
2026-02-28 12:57:34 -05:00
parent 5a2e1fda65
commit 1242550892
2 changed files with 38 additions and 38 deletions
+21 -21
View File
@@ -47,14 +47,14 @@ func TestSystemSettingsHandler(t *testing.T) {
var response map[string]interface{}
err := json.NewDecoder(rec.Body).Decode(&response)
require.NoError(t, err)
assert.Contains(t, response, "scan_frequency_minutes")
assert.Contains(t, response, "scan_poll_interval_seconds")
assert.Contains(t, response, "auto_scan_enabled")
})
t.Run("PUT /api/libraries/scan-settings - Update without auth", func(t *testing.T) {
payload := map[string]interface{}{
"scan_frequency_minutes": 30,
"auto_scan_enabled": true,
"scan_poll_interval_seconds": 30,
"auto_scan_enabled": true,
}
jsonData, _ := json.Marshal(payload)
@@ -70,8 +70,8 @@ func TestSystemSettingsHandler(t *testing.T) {
token := setup.RegularToken
payload := map[string]interface{}{
"scan_frequency_minutes": 30,
"auto_scan_enabled": true,
"scan_poll_interval_seconds": 30,
"auto_scan_enabled": true,
}
jsonData, _ := json.Marshal(payload)
@@ -88,8 +88,8 @@ func TestSystemSettingsHandler(t *testing.T) {
token := setup.Token
testCases := []struct {
name string
scanFrequencyMinutes int
name string
ScanPollIntervalSeconds int
}{
{"Frequency too low (14 minutes)", 14},
{"Frequency too high (1441 minutes)", 1441},
@@ -100,8 +100,8 @@ func TestSystemSettingsHandler(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
payload := map[string]interface{}{
"scan_frequency_minutes": tc.scanFrequencyMinutes,
"auto_scan_enabled": true,
"scan_poll_interval_seconds": tc.ScanPollIntervalSeconds,
"auto_scan_enabled": true,
}
jsonData, _ := json.Marshal(payload)
@@ -137,9 +137,9 @@ func TestSystemSettingsHandler(t *testing.T) {
token := setup.Token
testCases := []struct {
name string
scanFrequencyMinutes int
autoScanEnabled bool
name string
ScanPollIntervalSeconds int
autoScanEnabled bool
}{
{"Valid frequency (15 minutes)", 15, true},
{"Valid frequency (60 minutes)", 60, true},
@@ -151,8 +151,8 @@ func TestSystemSettingsHandler(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
payload := map[string]interface{}{
"scan_frequency_minutes": tc.scanFrequencyMinutes,
"auto_scan_enabled": tc.autoScanEnabled,
"scan_poll_interval_seconds": tc.ScanPollIntervalSeconds,
"auto_scan_enabled": tc.autoScanEnabled,
}
jsonData, _ := json.Marshal(payload)
@@ -167,7 +167,7 @@ func TestSystemSettingsHandler(t *testing.T) {
var response map[string]interface{}
err := json.NewDecoder(rec.Body).Decode(&response)
require.NoError(t, err)
assert.Equal(t, float64(tc.scanFrequencyMinutes), response["scan_frequency_minutes"])
assert.Equal(t, float64(tc.ScanPollIntervalSeconds), response["scan_poll_interval_seconds"])
assert.Equal(t, tc.autoScanEnabled, response["auto_scan_enabled"])
})
}
@@ -176,7 +176,7 @@ func TestSystemSettingsHandler(t *testing.T) {
t.Run("PUT /api/libraries/scan-settings - Update with invalid JSON", func(t *testing.T) {
token := setup.Token
invalidJSON := []byte(`{scan_frequency_minutes: 60, auto_scan_enabled: true}`)
invalidJSON := []byte(`{scan_poll_interval_seconds: 60, auto_scan_enabled: true}`)
req := httptest.NewRequest("PUT", "/api/libraries/scan-settings", bytes.NewBuffer(invalidJSON))
req.Header.Set("Content-Type", "application/json")
@@ -192,18 +192,18 @@ func TestSystemSettingsHandler(t *testing.T) {
func TestSystemSettingsIntegration(t *testing.T) {
t.Run("System settings affect all libraries equally", func(t *testing.T) {
settings := map[string]interface{}{
"scan_frequency_minutes": 60,
"auto_scan_enabled": true,
"scan_poll_interval_seconds": 60,
"auto_scan_enabled": true,
}
assert.Equal(t, 60, settings["scan_frequency_minutes"])
assert.Equal(t, 60, settings["scan_poll_interval_seconds"])
assert.Equal(t, true, settings["auto_scan_enabled"])
})
t.Run("Disabling auto scan stops all library scans", func(t *testing.T) {
settings := map[string]interface{}{
"scan_frequency_minutes": 60,
"auto_scan_enabled": false,
"scan_poll_interval_seconds": 60,
"auto_scan_enabled": false,
}
assert.Equal(t, false, settings["auto_scan_enabled"])