mirror of
https://github.com/kerberos-io/agent.git
synced 2026-08-23 15:08:32 +00:00
Treat nil, zero, and negative pixel-change thresholds as the historical default of 150, removing the disabled-motion behavior and adding configuration tests.
41 lines
1.0 KiB
Go
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
|
|
}
|