Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
NortonBen committed Oct 29, 2022
1 parent 6b2b04d commit 098ad83
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 1 deletion.
96 changes: 96 additions & 0 deletions rules/arithmetic/match_rule_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package arithmetic

import (
"context"
"github.com/dipper-iot/dipper-engine/data"
"github.com/dipper-iot/dipper-engine/queue"
"testing"
)

func TestMatchRule_Run(t *testing.T) {
a := NewArithmetic()
a.Infinity()
a.Initialize(context.TODO(), map[string]interface{}{})
qsub := queue.NewDefaultQueue[*data.InputEngine]("qsub")
qpub := queue.NewDefaultQueue[*data.OutputEngine]("qpub")

qsub.Publish(context.TODO(), &data.InputEngine{
SessionId: 1,
ChanId: "1",
IdNode: "noed1",
FromEngine: "test",
ToEngine: "test",
Node: &data.NodeRule{
Option: map[string]interface{}{
"operator": map[string]interface{}{
"right": map[string]interface{}{
"value": "default.a",
"type": "val",
},
"left": map[string]interface{}{
"type": "val",
"value": "default.b",
},
"operator": "+",
"type": "operator",
},
"set_param_result_to": "default.cond_a_b",
"next_error": "4",
"next_true": "4",
"next_false": "4",
},
End: false,
Debug: false,
RuleId: "1",
NodeId: "1",
},
Data: map[string]interface{}{
"default": map[string]interface{}{
"a": 2,
"b": 2,
"x": 3,
},
},
BranchMain: "default",
})
qsub.Publish(context.TODO(), &data.InputEngine{
SessionId: 1,
ChanId: "1",
IdNode: "noed1",
FromEngine: "test",
ToEngine: "test",
Node: &data.NodeRule{
Option: map[string]interface{}{
"operator": map[string]interface{}{
"right": map[string]interface{}{
"value": "default.f",
"type": "val",
},
"left": map[string]interface{}{
"type": "val",
"value": "default.b",
},
"operator": "-",
"type": "operator",
},
"set_param_result_to": "default.cond_a_b",
"next_error": "4",
"next_true": "4",
"next_false": "4",
},
End: false,
Debug: false,
RuleId: "1",
NodeId: "1",
},
Data: map[string]interface{}{
"default": map[string]interface{}{
"a": 2,
"b": 2,
"x": 3,
},
},
BranchMain: "default",
})
a.Run(context.TODO(), qsub.Subscribe, qpub.Publish)
}
3 changes: 2 additions & 1 deletion rules/conditional/conditional_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
)

func TestConditionalRule_Run(t *testing.T) {
a := ConditionalRule{}
a := NewConditionalRule()
a.Infinity()
a.Initialize(context.TODO(), map[string]interface{}{})
qsub := queue.NewDefaultQueue[*data.InputEngine]("qsub")
qpub := queue.NewDefaultQueue[*data.OutputEngine]("qpub")
Expand Down

0 comments on commit 098ad83

Please sign in to comment.