@@ -55,3 +55,37 @@ func TestGetMonitorSettingPreservesAutoBanOnlyMode(t *testing.T) {
|
||||
require.NotNil(t, setting)
|
||||
assert.Equal(t, ChannelTestModeAutoBanOnly, setting.ChannelTestMode)
|
||||
}
|
||||
|
||||
func TestGetMonitorSettingNormalizesChannelTestConcurrency(t *testing.T) {
|
||||
orig := monitorSetting
|
||||
t.Cleanup(func() { monitorSetting = orig })
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
concurrency int
|
||||
want int
|
||||
}{
|
||||
{name: "missing uses safe default", concurrency: 0, want: DefaultChannelTestConcurrency},
|
||||
{name: "configured value is preserved", concurrency: 8, want: 8},
|
||||
{name: "oversized value is capped", concurrency: MaxChannelTestConcurrency + 1, want: MaxChannelTestConcurrency},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
monitorSetting = MonitorSetting{ChannelTestConcurrency: test.concurrency}
|
||||
|
||||
setting := GetMonitorSetting()
|
||||
|
||||
require.NotNil(t, setting)
|
||||
assert.Equal(t, test.want, setting.ChannelTestConcurrency)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateChannelTestConcurrency(t *testing.T) {
|
||||
require.NoError(t, ValidateChannelTestConcurrency("1"))
|
||||
require.NoError(t, ValidateChannelTestConcurrency("32"))
|
||||
assert.Error(t, ValidateChannelTestConcurrency("0"))
|
||||
assert.Error(t, ValidateChannelTestConcurrency("33"))
|
||||
assert.Error(t, ValidateChannelTestConcurrency("1.5"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user