@@ -0,0 +1,36 @@
|
||||
package appg
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestShortRecommendDefaultsPreserveLegacyDeployment(t *testing.T) {
|
||||
var nilConfig *GlobalConfig
|
||||
if !nilConfig.ShortRecommendEnabled() {
|
||||
t.Fatal("nil config should default to enabled")
|
||||
}
|
||||
if got := nilConfig.ShortRecommendRequestTimeout(); got != 3*time.Second {
|
||||
t.Fatalf("timeout = %v, want 3s", got)
|
||||
}
|
||||
if got := nilConfig.ShortRecommendKeyTTL(); got != 72 {
|
||||
t.Fatalf("TTL hours = %d, want 72", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortRecommendConfigBoundsTimeout(t *testing.T) {
|
||||
disabled := false
|
||||
cfg := &GlobalConfig{}
|
||||
cfg.ShortRecommend.Enabled = &disabled
|
||||
cfg.ShortRecommend.RequestTimeoutMs = 1
|
||||
if cfg.ShortRecommendEnabled() {
|
||||
t.Fatal("configured disabled should be honored")
|
||||
}
|
||||
if got := cfg.ShortRecommendRequestTimeout(); got != 100*time.Millisecond {
|
||||
t.Fatalf("minimum timeout = %v, want 100ms", got)
|
||||
}
|
||||
cfg.ShortRecommend.RequestTimeoutMs = 20_000
|
||||
if got := cfg.ShortRecommendRequestTimeout(); got != 10*time.Second {
|
||||
t.Fatalf("maximum timeout = %v, want 10s", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user