diff --git a/routingtable/filter/actions/as_path_prepend_action_test.go b/routingtable/filter/actions/as_path_prepend_action_test.go index 44ec18e9e693ce967a8369c75b12409c555f023c..c2fa140896c1e99f5d6abe69b812ac2c2c595134 100644 --- a/routingtable/filter/actions/as_path_prepend_action_test.go +++ b/routingtable/filter/actions/as_path_prepend_action_test.go @@ -12,18 +12,30 @@ func TestAppendPath(t *testing.T) { tests := []struct { name string times uint16 + bgpPath *route.BGPPath expectedPath string expectedLength uint16 }{ { - name: "append 0", - times: 0, + name: "BGPPath is nil", + }, + { + name: "append 0", + times: 0, + bgpPath: &route.BGPPath{ + ASPath: "12345 12345", + ASPathLen: 2, + }, expectedPath: "12345 12345", expectedLength: 2, }, { - name: "append 3", - times: 3, + name: "append 3", + times: 3, + bgpPath: &route.BGPPath{ + ASPath: "12345 12345", + ASPathLen: 2, + }, expectedPath: "12345 12345 12345 12345 12345", expectedLength: 5, }, @@ -33,12 +45,13 @@ func TestAppendPath(t *testing.T) { t.Run(test.name, func(te *testing.T) { a := NewASPathPrependAction(12345, test.times) p, _ := a.Do(net.NewPfx(strAddr("10.0.0.0"), 8), &route.Path{ - BGPPath: &route.BGPPath{ - ASPath: "12345 12345", - ASPathLen: 2, - }, + BGPPath: test.bgpPath, }) + if test.bgpPath == nil { + return + } + assert.Equal(te, test.expectedPath, p.BGPPath.ASPath, "ASPath") assert.Equal(te, test.expectedLength, p.BGPPath.ASPathLen, "ASPathLen") })