File tree 2 files changed +27
-2
lines changed
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ func FlowRulesJsonConverter(src []byte) (interface{}, error) {
24
24
// FlowRulesUpdater load the newest []flow.FlowRule to downstream flow component.
25
25
func FlowRulesUpdater (data interface {}) error {
26
26
if data == nil {
27
- return nil
27
+ return flow . ClearRules ()
28
28
}
29
29
30
30
rules := make ([]* flow.FlowRule , 0 )
@@ -64,7 +64,7 @@ func SystemRulesJsonConverter(src []byte) (interface{}, error) {
64
64
// SystemRulesUpdater load the newest []system.SystemRule to downstream system component.
65
65
func SystemRulesUpdater (data interface {}) error {
66
66
if data == nil {
67
- return nil
67
+ return system . ClearRules ()
68
68
}
69
69
70
70
rules := make ([]* system.SystemRule , 0 )
Original file line number Diff line number Diff line change @@ -81,6 +81,22 @@ func TestFlowRulesJsonConverter(t *testing.T) {
81
81
func TestFlowRulesUpdater (t * testing.T ) {
82
82
t .Run ("TestFlowRulesUpdater_Nil" , func (t * testing.T ) {
83
83
flow .ClearRules ()
84
+ flow .LoadRules ([]* flow.FlowRule {
85
+ {
86
+ ID : 0 ,
87
+ Resource : "abc" ,
88
+ LimitOrigin : "default" ,
89
+ MetricType : 0 ,
90
+ Count : 0 ,
91
+ RelationStrategy : 0 ,
92
+ ControlBehavior : 0 ,
93
+ RefResource : "" ,
94
+ WarmUpPeriodSec : 0 ,
95
+ MaxQueueingTimeMs : 0 ,
96
+ ClusterMode : false ,
97
+ ClusterConfig : flow.ClusterRuleConfig {},
98
+ }})
99
+ assert .True (t , len (flow .GetRules ()) == 1 , "Fail to prepare test data." )
84
100
err := FlowRulesUpdater (nil )
85
101
assert .True (t , err == nil && len (flow .GetRules ()) == 0 , "Fail to test TestFlowRulesUpdater_Nil" )
86
102
})
@@ -189,6 +205,15 @@ func TestSystemRulesJsonConvert(t *testing.T) {
189
205
func TestSystemRulesUpdater (t * testing.T ) {
190
206
t .Run ("TestSystemRulesUpdater_Nil" , func (t * testing.T ) {
191
207
system .ClearRules ()
208
+ system .LoadRules ([]* system.SystemRule {
209
+ & system.SystemRule {
210
+ ID : 0 ,
211
+ MetricType : 0 ,
212
+ TriggerCount : 0 ,
213
+ Strategy : 0 ,
214
+ },
215
+ })
216
+ assert .True (t , len (system .GetRules ()) == 1 , "Fail to prepare data." )
192
217
err := SystemRulesUpdater (nil )
193
218
assert .True (t , err == nil && len (system .GetRules ()) == 0 , "Fail to test TestSystemRulesUpdater_Nil" )
194
219
})
You can’t perform that action at this time.
0 commit comments