Skip to content

Commit

Permalink
reverting unwanted changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpark800 committed May 3, 2019
1 parent 2680a03 commit 6ceb530
Showing 1 changed file with 7 additions and 50 deletions.
57 changes: 7 additions & 50 deletions ruleapi/tests/rtctxn_8_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"testing"
)

//no-identifier condition with single-assertion
func Test_T8_1(t *testing.T) {
//no-identifier condition
func Test_T8(t *testing.T) {

rs, _ := createRuleSession()

Expand All @@ -21,7 +21,7 @@ func Test_T8_1(t *testing.T) {
rs.AddRule(rule)
t.Logf("Rule added: [%s]\n", rule.GetName())

rs.RegisterRtcTransactionHandler(t8Handler_1, t)
rs.RegisterRtcTransactionHandler(t8Handler, t)
rs.Start(nil)

t1, _ := model.NewTupleWithKeyValues("t1", "t1")
Expand All @@ -30,63 +30,20 @@ func Test_T8_1(t *testing.T) {

}

//no-identifier condition with multi-assertion
func Test_T8_2(t *testing.T) {

rs, _ := createRuleSession()

rule := ruleapi.NewRule("R1")
rule.AddCondition("R1_c1", []string{"t1.none"}, trueCondition, nil)
rule.AddCondition("R1_c2", []string{}, trueCondition, nil)
rule.SetAction(assertTuple)
rule.SetPriority(1)
rs.AddRule(rule)
t.Logf("Rule added: [%s]\n", rule.GetName())

rs.RegisterRtcTransactionHandler(t8Handler_2, t)
rs.Start(nil)

t1, _ := model.NewTupleWithKeyValues("t1", "t1")
rs.Assert(context.TODO(), t1)
rs.Unregister()

}

func assertTuple(ctx context.Context, rs model.RuleSession, ruleName string, tuples map[model.TupleType]model.Tuple, ruleCtx model.RuleContext) {
t, _ := model.NewTupleWithKeyValues("t1", "t2")
t, _:= model.NewTupleWithKeyValues("t1", "t2")
rs.Assert(ctx, t)
}

func t8Handler_1(ctx context.Context, rs model.RuleSession, rtxn model.RtcTxn, handlerCtx interface{}) {
func t8Handler(ctx context.Context, rs model.RuleSession, rtxn model.RtcTxn, handlerCtx interface{}) {

t := handlerCtx.(*testing.T)
if m, found := rtxn.GetRtcAdded()["t1"]; found {
lA := len(m)
if lA != 1 {
t.Errorf("RtcAdded: Expected [%d], got [%d]\n", 1, lA)
printTuples(t, "Added", rtxn.GetRtcAdded())
}
}
lM := len(rtxn.GetRtcModified())
if lM != 0 {
t.Errorf("RtcModified: Expected [%d], got [%d]\n", 0, lM)
printModified(t, rtxn.GetRtcModified())
}
lD := len(rtxn.GetRtcDeleted())
if lD != 0 {
t.Errorf("RtcDeleted: Expected [%d], got [%d]\n", 0, lD)
printTuples(t, "Deleted", rtxn.GetRtcDeleted())
}
}

func t8Handler_2(ctx context.Context, rs model.RuleSession, rtxn model.RtcTxn, handlerCtx interface{}) {

t := handlerCtx.(*testing.T)
if m, found := rtxn.GetRtcAdded()["t1"]; found {
lA := len(m)
if lA != 2 {
t.Errorf("RtcAdded: Expected [%d], got [%d]\n", 1, lA)
printTuples(t, "Added", rtxn.GetRtcAdded())
printTuples(t,"Added", rtxn.GetRtcAdded())
}
}
lM := len(rtxn.GetRtcModified())
Expand All @@ -97,6 +54,6 @@ func t8Handler_2(ctx context.Context, rs model.RuleSession, rtxn model.RtcTxn, h
lD := len(rtxn.GetRtcDeleted())
if lD != 0 {
t.Errorf("RtcDeleted: Expected [%d], got [%d]\n", 0, lD)
printTuples(t, "Deleted", rtxn.GetRtcDeleted())
printTuples(t,"Deleted", rtxn.GetRtcDeleted())
}
}

0 comments on commit 6ceb530

Please sign in to comment.