Skip to content
Snippets Groups Projects
Commit 62d6d0c8 authored by Daniel Czerwonk's avatar Daniel Czerwonk
Browse files

added test

parent 562fa33c
No related branches found
No related tags found
No related merge requests found
...@@ -12,18 +12,30 @@ func TestAppendPath(t *testing.T) { ...@@ -12,18 +12,30 @@ func TestAppendPath(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
times uint16 times uint16
bgpPath *route.BGPPath
expectedPath string expectedPath string
expectedLength uint16 expectedLength uint16
}{ }{
{ {
name: "append 0", name: "BGPPath is nil",
times: 0, },
{
name: "append 0",
times: 0,
bgpPath: &route.BGPPath{
ASPath: "12345 12345",
ASPathLen: 2,
},
expectedPath: "12345 12345", expectedPath: "12345 12345",
expectedLength: 2, expectedLength: 2,
}, },
{ {
name: "append 3", name: "append 3",
times: 3, times: 3,
bgpPath: &route.BGPPath{
ASPath: "12345 12345",
ASPathLen: 2,
},
expectedPath: "12345 12345 12345 12345 12345", expectedPath: "12345 12345 12345 12345 12345",
expectedLength: 5, expectedLength: 5,
}, },
...@@ -33,12 +45,13 @@ func TestAppendPath(t *testing.T) { ...@@ -33,12 +45,13 @@ func TestAppendPath(t *testing.T) {
t.Run(test.name, func(te *testing.T) { t.Run(test.name, func(te *testing.T) {
a := NewASPathPrependAction(12345, test.times) a := NewASPathPrependAction(12345, test.times)
p, _ := a.Do(net.NewPfx(strAddr("10.0.0.0"), 8), &route.Path{ p, _ := a.Do(net.NewPfx(strAddr("10.0.0.0"), 8), &route.Path{
BGPPath: &route.BGPPath{ BGPPath: test.bgpPath,
ASPath: "12345 12345",
ASPathLen: 2,
},
}) })
if test.bgpPath == nil {
return
}
assert.Equal(te, test.expectedPath, p.BGPPath.ASPath, "ASPath") assert.Equal(te, test.expectedPath, p.BGPPath.ASPath, "ASPath")
assert.Equal(te, test.expectedLength, p.BGPPath.ASPathLen, "ASPathLen") assert.Equal(te, test.expectedLength, p.BGPPath.ASPathLen, "ASPathLen")
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment