Files
agent/machinery/src/config/main_test.go
Cédric Verstraeten 704011c20b Restore motion threshold defaults
Treat nil, zero, and negative pixel-change thresholds as the historical default of 150, removing the disabled-motion behavior and adding configuration tests.
2026-08-05 14:04:46 +02:00

41 lines
1.0 KiB
Go

package config
import (
"testing"
"github.com/kerberos-io/agent/machinery/src/models"
)
func TestApplyAgentEnvVarsPixelChangeThresholdDefault(t *testing.T) {
tests := []struct {
name string
threshold *int
want int
}{
{name: "missing", want: 150},
{name: "legacy zero", threshold: intPointer(0), want: 150},
{name: "negative", threshold: intPointer(-1), want: 150},
{name: "positive", threshold: intPointer(275), want: 275},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
configuration := &models.Configuration{}
configuration.Config.Capture.PixelChangeThreshold = test.threshold
applyAgentEnvVars(configuration, "TEST_", true)
if configuration.Config.Capture.PixelChangeThreshold == nil {
t.Fatal("PixelChangeThreshold is nil after applying defaults")
}
if got := *configuration.Config.Capture.PixelChangeThreshold; got != test.want {
t.Fatalf("PixelChangeThreshold = %d, want %d", got, test.want)
}
})
}
}
func intPointer(value int) *int {
return &value
}