Add route tests for receiver inheritance

Tests for:
- inheriting a receiver from the default route
- overriding the receiver when the parent route has not set one
- inheriting a receiver from a parent route that's not the default

Adds a route which matches on a `group_by` label which inherits the
default receiver and also has a child route, matching on an `env` label,
which overrides the receiver.

To be sure of edge case behaviour, we test inheriting the receiver from
a child route. Hopefully no one would actually implement this edge case
in reality as it's overly complex but we test anyway to be sure that it
doesn't trigger unexpected behaviour.
This commit is contained in:
Matt Bostock 2016-06-04 10:08:08 +01:00
parent a29860d80e
commit aec84c0288
1 changed files with 58 additions and 0 deletions

View File

@ -65,6 +65,19 @@ routes:
group_by: ['foo', 'bar']
group_wait: 2m
receiver: 'notify-BC'
- match:
group_by: 'role'
group_by: ['role']
routes:
- match:
env: 'testing'
receiver: 'notify-testing'
routes:
- match:
wait: 'long'
group_wait: 2m
`
var ctree config.Route
@ -167,6 +180,51 @@ routes:
},
},
},
{
input: model.LabelSet{
"group_by": "role",
},
result: []*RouteOpts{
{
Receiver: "notify-def",
GroupBy: lset("role"),
GroupWait: def.GroupWait,
GroupInterval: def.GroupInterval,
RepeatInterval: def.RepeatInterval,
},
},
},
{
input: model.LabelSet{
"env": "testing",
"group_by": "role",
},
result: []*RouteOpts{
{
Receiver: "notify-testing",
GroupBy: lset("role"),
GroupWait: def.GroupWait,
GroupInterval: def.GroupInterval,
RepeatInterval: def.RepeatInterval,
},
},
},
{
input: model.LabelSet{
"env": "testing",
"group_by": "role",
"wait": "long",
},
result: []*RouteOpts{
{
Receiver: "notify-testing",
GroupBy: lset("role"),
GroupWait: 2 * time.Minute,
GroupInterval: def.GroupInterval,
RepeatInterval: def.RepeatInterval,
},
},
},
}
for _, test := range tests {