From b2bb6f784b8c98d1fdee49c50fd93181da2ac8ca Mon Sep 17 00:00:00 2001
From: Daniel Czerwonk <daniel@dan-nrw.de>
Date: Thu, 17 May 2018 11:46:35 +0200
Subject: [PATCH] added test

---
 .../actions/as_path_prepend_action_test.go    | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 routingtable/filter/actions/as_path_prepend_action_test.go

diff --git a/routingtable/filter/actions/as_path_prepend_action_test.go b/routingtable/filter/actions/as_path_prepend_action_test.go
new file mode 100644
index 00000000..44ec18e9
--- /dev/null
+++ b/routingtable/filter/actions/as_path_prepend_action_test.go
@@ -0,0 +1,46 @@
+package actions
+
+import (
+	"testing"
+
+	"github.com/bio-routing/bio-rd/net"
+	"github.com/bio-routing/bio-rd/route"
+	"github.com/stretchr/testify/assert"
+)
+
+func TestAppendPath(t *testing.T) {
+	tests := []struct {
+		name           string
+		times          uint16
+		expectedPath   string
+		expectedLength uint16
+	}{
+		{
+			name:           "append 0",
+			times:          0,
+			expectedPath:   "12345 12345",
+			expectedLength: 2,
+		},
+		{
+			name:           "append 3",
+			times:          3,
+			expectedPath:   "12345 12345 12345 12345 12345",
+			expectedLength: 5,
+		},
+	}
+
+	for _, test := range tests {
+		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,
+				},
+			})
+
+			assert.Equal(te, test.expectedPath, p.BGPPath.ASPath, "ASPath")
+			assert.Equal(te, test.expectedLength, p.BGPPath.ASPathLen, "ASPathLen")
+		})
+	}
+}
-- 
GitLab