Skip to content

Commit 106bc43

Browse files
committed
fix comments
Signed-off-by: Yijie Qin <[email protected]>
1 parent 3d052d9 commit 106bc43

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

dispatch/route.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ func (r *Route) Key() string {
180180
return b.String()
181181
}
182182

183-
// ID returns a key for the route. It should uniquely identify the route in general,
184-
// it is different than Key() as it adds the route's position on its parent's children.
183+
// ID returns a unique identifier for the route, unlike Key().
185184
func (r *Route) ID() string {
186185
b := strings.Builder{}
187186

dispatch/route_test.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -909,22 +909,24 @@ routes:
909909
}
910910
tree := NewRoute(&ctree, nil)
911911

912-
tests := []struct {
913-
id string
914-
}{
915-
{
916-
id: "{}/{level!=\"critical\",owner=\"team-A\"}/0",
917-
},
918-
{
919-
id: "{}/{owner=~\"^(?:team-(B|C))$\"}/1",
920-
},
921-
{
922-
id: "{}/{group_by=\"role\"}/2",
923-
},
912+
expected := []string{
913+
"{}",
914+
"{}/{level!=\"critical\",owner=\"team-A\"}/0",
915+
"{}/{level!=\"critical\",owner=\"team-A\"}/{baz!~\".*quux\",env=\"testing\"}/0",
916+
"{}/{level!=\"critical\",owner=\"team-A\"}/{env=\"production\"}/1",
917+
"{}/{level!=\"critical\",owner=\"team-A\"}/{env=~\"produ.*\",job=~\".*\"}/2",
918+
"{}/{owner=~\"^(?:team-(B|C))$\"}/1",
919+
"{}/{group_by=\"role\"}/2",
920+
"{}/{group_by=\"role\"}/{env=\"testing\"}/0",
921+
"{}/{group_by=\"role\"}/{env=\"testing\"}/{wait=\"long\"}/0",
924922
}
925923

926-
for i, test := range tests {
927-
id := tree.Routes[i].ID()
928-
require.Equal(t, test.id, id)
924+
var got []string
925+
tree.Walk(func(r *Route) {
926+
got = append(got, r.ID())
927+
})
928+
929+
if !reflect.DeepEqual(got, expected) {
930+
t.Errorf("\nexpected:\n%v\ngot:\n%v", expected, got)
929931
}
930932
}

0 commit comments

Comments
 (0)