forked from QuantumNous/new-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor_setting_test.go
More file actions
43 lines (33 loc) · 1.09 KB
/
Copy pathmonitor_setting_test.go
File metadata and controls
43 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package operation_setting
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGetMonitorSetting_ChannelTestEnabledEnvOverridesEnabledConfig(t *testing.T) {
orig := monitorSetting
t.Cleanup(func() { monitorSetting = orig })
t.Setenv("CHANNEL_TEST_ENABLED", "false")
t.Setenv("CHANNEL_TEST_FREQUENCY", "5")
monitorSetting = MonitorSetting{
AutoTestChannelEnabled: true,
AutoTestChannelMinutes: 20,
}
setting := GetMonitorSetting()
require.NotNil(t, setting)
assert.False(t, setting.AutoTestChannelEnabled)
assert.Equal(t, float64(5), setting.AutoTestChannelMinutes)
}
func TestGetMonitorSetting_ChannelTestEnabledEnvCanEnableDisabledConfig(t *testing.T) {
orig := monitorSetting
t.Cleanup(func() { monitorSetting = orig })
t.Setenv("CHANNEL_TEST_ENABLED", "true")
monitorSetting = MonitorSetting{
AutoTestChannelEnabled: false,
AutoTestChannelMinutes: 12,
}
setting := GetMonitorSetting()
require.NotNil(t, setting)
assert.True(t, setting.AutoTestChannelEnabled)
assert.Equal(t, float64(12), setting.AutoTestChannelMinutes)
}