From 62d6d0c8b1b316e890a1ddb055573ba95667f604 Mon Sep 17 00:00:00 2001
From: Daniel Czerwonk <daniel@dan-nrw.de>
Date: Thu, 17 May 2018 12:01:45 +0200
Subject: [PATCH] added test

---
 .../actions/as_path_prepend_action_test.go    | 29 ++++++++++++++-----
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/routingtable/filter/actions/as_path_prepend_action_test.go b/routingtable/filter/actions/as_path_prepend_action_test.go
index 44ec18e9..c2fa1408 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")
 		})
-- 
GitLab