summaryrefslogtreecommitdiffhomepage
path: root/table/message_test.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-07 01:23:21 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-07 01:23:21 -0800
commit1268cfca64c46c963fed587b2197ebcd3750b367 (patch)
tree1bc33571f679233b69a2d31a768b1ecafe8fa664 /table/message_test.go
parent4bd5611c10bd668622f2dd1f7ad7cd72e889fcf4 (diff)
table: fix the previous commit
update unit tests. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/message_test.go')
-rw-r--r--table/message_test.go53
1 files changed, 6 insertions, 47 deletions
diff --git a/table/message_test.go b/table/message_test.go
index ce29d899..d72fa833 100644
--- a/table/message_test.go
+++ b/table/message_test.go
@@ -40,28 +40,6 @@ func updateMsg1(as []uint16) *bgp.BGPMessage {
return bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttributes, nlri)
}
-func TestAs4PathNonAsTrans(t *testing.T) {
- as := []uint16{65000, 4000, 40001}
- m := updateMsg1(as).Body.(*bgp.BGPUpdate)
- originalAsPath := m.PathAttributes[1]
- UpdatePathAttrs4ByteAs(m)
- assert.Equal(t, reflect.TypeOf(m.PathAttributes[0]).String(), "*bgp.PathAttributeOrigin")
- assert.Equal(t, reflect.TypeOf(m.PathAttributes[1]).String(), "*bgp.PathAttributeAsPath")
- assert.Equal(t, reflect.TypeOf(m.PathAttributes[2]).String(), "*bgp.PathAttributeNextHop")
- assert.Equal(t, reflect.TypeOf(m.PathAttributes[3]).String(), "*bgp.PathAttributeMultiExitDisc")
-
- asAttr := m.PathAttributes[1].(*bgp.PathAttributeAsPath)
- assert.Equal(t, len(asAttr.Value), 1)
- for _, param := range asAttr.Value {
- asParam := param.(*bgp.As4PathParam)
- for i, v := range asParam.AS {
- assert.Equal(t, v, as[i])
- }
- }
- UpdatePathAttrs2ByteAs(m)
- assert.Equal(t, m.PathAttributes[1], originalAsPath)
-}
-
func TestAsPathAsTrans(t *testing.T) {
as := []uint16{65000, 4000, bgp.AS_TRANS, bgp.AS_TRANS, 40001}
m := updateMsg1(as).Body.(*bgp.BGPUpdate)
@@ -72,8 +50,6 @@ func TestAsPathAsTrans(t *testing.T) {
m.PathAttributes[3] = bgp.NewPathAttributeAs4Path(aspathParam)
assert.Equal(t, len(m.PathAttributes), 5)
- originalAsPath := m.PathAttributes[1]
- originalAs4Path := m.PathAttributes[3]
UpdatePathAttrs4ByteAs(m)
assert.Equal(t, len(m.PathAttributes), 4)
@@ -93,8 +69,12 @@ func TestAsPathAsTrans(t *testing.T) {
}
UpdatePathAttrs2ByteAs(m)
assert.Equal(t, len(m.PathAttributes), 5)
- assert.Equal(t, m.PathAttributes[1], originalAsPath)
- assert.Equal(t, m.PathAttributes[4], originalAs4Path)
+ attr := m.PathAttributes[1].(*bgp.PathAttributeAsPath)
+ assert.Equal(t, len(attr.Value), 1)
+ assert.Equal(t, attr.Value[0].(*bgp.AsPathParam).AS, as)
+ attr2 := m.PathAttributes[4].(*bgp.PathAttributeAs4Path)
+ assert.Equal(t, len(attr2.Value), 1)
+ assert.Equal(t, attr2.Value[0].AS, as4)
}
func TestAs4PathUnchanged(t *testing.T) {
@@ -119,24 +99,3 @@ func TestAs4PathUnchanged(t *testing.T) {
}
}
}
-
-func TestAsPathUnchanged(t *testing.T) {
- as := []uint16{65000, 4000, 5000, 4001}
- m := updateMsg1(as).Body.(*bgp.BGPUpdate)
- UpdatePathAttrs2ByteAs(m)
- assert.Equal(t, len(m.PathAttributes), 4)
-
- assert.Equal(t, reflect.TypeOf(m.PathAttributes[0]).String(), "*bgp.PathAttributeOrigin")
- assert.Equal(t, reflect.TypeOf(m.PathAttributes[1]).String(), "*bgp.PathAttributeAsPath")
- assert.Equal(t, reflect.TypeOf(m.PathAttributes[2]).String(), "*bgp.PathAttributeNextHop")
- assert.Equal(t, reflect.TypeOf(m.PathAttributes[3]).String(), "*bgp.PathAttributeMultiExitDisc")
-
- asAttr := m.PathAttributes[1].(*bgp.PathAttributeAsPath)
- assert.Equal(t, len(asAttr.Value), 1)
- for _, param := range asAttr.Value {
- asParam := param.(*bgp.AsPathParam)
- for i, v := range asParam.AS {
- assert.Equal(t, v, as[i])
- }
- }
-}