(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestMergeGroupStateDesc(t *testing.T) { |
| 16 | curTime := time.Now() |
| 17 | r := rulespb.RuleDesc{ |
| 18 | Expr: "1 > 1", |
| 19 | } |
| 20 | g1 := rulespb.RuleGroupDesc{ |
| 21 | Name: "g1", |
| 22 | Namespace: "ns1", |
| 23 | } |
| 24 | g2 := rulespb.RuleGroupDesc{ |
| 25 | Name: "g2", |
| 26 | Namespace: "ns1", |
| 27 | } |
| 28 | rs1 := RuleStateDesc{ |
| 29 | Rule: &r, |
| 30 | EvaluationTimestamp: curTime, |
| 31 | } |
| 32 | rs1NotRun := RuleStateDesc{ |
| 33 | Rule: &r, |
| 34 | } |
| 35 | rs2 := RuleStateDesc{ |
| 36 | Rule: &r, |
| 37 | EvaluationTimestamp: curTime, |
| 38 | } |
| 39 | rs2NotRun := RuleStateDesc{ |
| 40 | Rule: &r, |
| 41 | } |
| 42 | rs3 := RuleStateDesc{ |
| 43 | Rule: &r, |
| 44 | EvaluationTimestamp: curTime.Add(10 * time.Second), |
| 45 | } |
| 46 | |
| 47 | gs1 := GroupStateDesc{ |
| 48 | Group: &g1, |
| 49 | ActiveRules: []*RuleStateDesc{&rs1, &rs2}, |
| 50 | EvaluationTimestamp: curTime, |
| 51 | } |
| 52 | gs1NotRun := GroupStateDesc{ |
| 53 | Group: &g1, |
| 54 | ActiveRules: []*RuleStateDesc{&rs1NotRun, &rs2NotRun}, |
| 55 | } |
| 56 | gs2 := GroupStateDesc{ |
| 57 | Group: &g2, |
| 58 | ActiveRules: []*RuleStateDesc{&rs1, &rs2}, |
| 59 | EvaluationTimestamp: curTime, |
| 60 | } |
| 61 | gs2NotRun := GroupStateDesc{ |
| 62 | Group: &g2, |
| 63 | ActiveRules: []*RuleStateDesc{&rs1NotRun, &rs2NotRun}, |
| 64 | } |
| 65 | gs3 := GroupStateDesc{ |
| 66 | Group: &g2, |
| 67 | ActiveRules: []*RuleStateDesc{&rs1, &rs3}, |
| 68 | EvaluationTimestamp: curTime, |
| 69 | } |
| 70 | |
| 71 | type testCase struct { |
| 72 | input []*RulesResponse |
nothing calls this directly
no test coverage detected