0.1.52 Gateway

This commit is contained in:
ponzischeme89
2026-08-17 19:09:17 +12:00
parent d5a8d3ad88
commit 1da91e40a1
46 changed files with 1626 additions and 106 deletions
@@ -0,0 +1,47 @@
package store
import "testing"
// Normalisation is what stands between a hand-edited row (or a console built against an
// older vocabulary) and a gateway that cannot decide what day it is.
func TestNormalizeGatewaySettingsRefusesWhatItCannotUse(t *testing.T) {
settings := normalizeGatewaySettings(GatewaySettings{
Timezone: " Not/AZone ", LogLevel: "LOUD", SessionIdleDays: -4,
})
if settings.Timezone != "" {
t.Fatalf("an unloadable timezone should be dropped, got %q", settings.Timezone)
}
if settings.LogLevel != "" {
t.Fatalf("an unknown level should be dropped, got %q", settings.LogLevel)
}
// Session expiry cannot be switched off — a household with no expiry at all is a
// database full of live Emby tokens — so a negative reads as "leave it alone".
if settings.SessionIdleDays != 0 {
t.Fatalf("session expiry should not be switchable off, got %d", settings.SessionIdleDays)
}
}
func TestNormalizeGatewaySettingsKeepsTheThreeMeanings(t *testing.T) {
settings := normalizeGatewaySettings(GatewaySettings{
Timezone: "Pacific/Auckland", LogLevel: " Debug ",
SonarrAlertMinutes: -9, RadarrAlertMinutes: 0, EmbyHealthSeconds: 5,
})
if settings.Timezone != "Pacific/Auckland" {
t.Fatalf("a real zone should survive, got %q", settings.Timezone)
}
if settings.LogLevel != "debug" {
t.Fatalf("a level should be trimmed and folded, got %q", settings.LogLevel)
}
if settings.SonarrAlertMinutes != GatewaySettingsOff {
t.Fatalf("every negative should collapse to the one off value, got %d",
settings.SonarrAlertMinutes)
}
if settings.RadarrAlertMinutes != 0 {
t.Fatalf("zero must keep meaning deployed, got %d", settings.RadarrAlertMinutes)
}
// Below the floor rather than refused: an operator asking for a five-second probe has
// said "as often as possible", and the answer to that is the fastest allowed.
if settings.EmbyHealthSeconds != 10 {
t.Fatalf("a value under the floor should clamp to it, got %d", settings.EmbyHealthSeconds)
}
}