0.3.49
This commit is contained in:
@@ -2,6 +2,31 @@ package store
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNormalizeGatewaySettingsCacheAndRebuildOverrides(t *testing.T) {
|
||||
hour := 25
|
||||
settings := normalizeGatewaySettings(GatewaySettings{
|
||||
HomeTTLSeconds: 2, RecommendTTLHours: 500, ForYouRebuildHour: &hour,
|
||||
})
|
||||
// TTLs cannot be switched off, so a sub-floor value clamps up and an over-ceiling one
|
||||
// clamps down rather than either reading as "deployed".
|
||||
if settings.HomeTTLSeconds != 5 {
|
||||
t.Fatalf("home TTL should clamp to the floor, got %d", settings.HomeTTLSeconds)
|
||||
}
|
||||
if settings.RecommendTTLHours != 168 {
|
||||
t.Fatalf("recommend TTL should clamp to the ceiling, got %d", settings.RecommendTTLHours)
|
||||
}
|
||||
// An hour outside the clock is a typo, and is dropped rather than clamped.
|
||||
if settings.ForYouRebuildHour != nil {
|
||||
t.Fatalf("an out-of-range rebuild hour should be dropped, got %d", *settings.ForYouRebuildHour)
|
||||
}
|
||||
|
||||
valid := 0
|
||||
kept := normalizeGatewaySettings(GatewaySettings{ForYouRebuildHour: &valid})
|
||||
if kept.ForYouRebuildHour == nil || *kept.ForYouRebuildHour != 0 {
|
||||
t.Fatalf("midnight is a legitimate rebuild hour and must survive, got %v", kept.ForYouRebuildHour)
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
||||
Reference in New Issue
Block a user