summaryrefslogtreecommitdiffhomepage
path: root/table/table_test.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-04-27 11:02:42 +0000
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-04-27 15:20:51 +0000
commit87a951546c43cb70ad3a03ec42de7cead8d25d72 (patch)
tree62e79e2dea8ae5a6a8f13c7f88f9cd3d0eaf3a29 /table/table_test.go
parent91cb8ea23f454592be9fb4565f0f477afdbcb0ec (diff)
table: make table.ProcessMessage a function
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/table_test.go')
-rw-r--r--table/table_test.go28
1 files changed, 9 insertions, 19 deletions
diff --git a/table/table_test.go b/table/table_test.go
index 70e9c86b..fe15204c 100644
--- a/table/table_test.go
+++ b/table/table_test.go
@@ -38,8 +38,7 @@ func TestTableTableKeyDefault(t *testing.T) {
func TestTableDeleteDestByNlri(t *testing.T) {
peerT := TableCreatePeer()
- msgT := TableCreateMSG(peerT)
- pathT := TableCreatePath(msgT)
+ pathT := TableCreatePath(peerT)
ipv4t := NewIPv4Table(0)
for _, path := range pathT {
tableKey := ipv4t.tableKey(path.GetNlri())
@@ -54,8 +53,7 @@ func TestTableDeleteDestByNlri(t *testing.T) {
func TestTableDeleteDest(t *testing.T) {
peerT := TableCreatePeer()
- msgT := TableCreateMSG(peerT)
- pathT := TableCreatePath(msgT)
+ pathT := TableCreatePath(peerT)
ipv4t := NewIPv4Table(0)
for _, path := range pathT {
tableKey := ipv4t.tableKey(path.GetNlri())
@@ -78,8 +76,7 @@ func TestTableGetRouteFamily(t *testing.T) {
func TestTableSetDestinations(t *testing.T) {
peerT := TableCreatePeer()
- msgT := TableCreateMSG(peerT)
- pathT := TableCreatePath(msgT)
+ pathT := TableCreatePath(peerT)
ipv4t := NewIPv4Table(0)
destinations := make(map[string]Destination)
for _, path := range pathT {
@@ -93,8 +90,7 @@ func TestTableSetDestinations(t *testing.T) {
}
func TestTableGetDestinations(t *testing.T) {
peerT := DestCreatePeer()
- msgT := DestCreateMSG(peerT)
- pathT := DestCreatePath(msgT)
+ pathT := DestCreatePath(peerT)
ipv4t := NewIPv4Table(0)
destinations := make(map[string]Destination)
for _, path := range pathT {
@@ -114,24 +110,18 @@ func TableCreatePeer() []*PeerInfo {
peerT := []*PeerInfo{peerT1, peerT2, peerT3}
return peerT
}
-func TableCreateMSG(peerT []*PeerInfo) []*ProcessMessage {
+
+func TableCreatePath(peerT []*PeerInfo) []Path {
bgpMsgT1 := updateMsgT1()
bgpMsgT2 := updateMsgT2()
bgpMsgT3 := updateMsgT3()
- msgT1 := &ProcessMessage{innerMessage: bgpMsgT1, fromPeer: peerT[0]}
- msgT2 := &ProcessMessage{innerMessage: bgpMsgT2, fromPeer: peerT[1]}
- msgT3 := &ProcessMessage{innerMessage: bgpMsgT3, fromPeer: peerT[2]}
- msgT := []*ProcessMessage{msgT1, msgT2, msgT3}
- return msgT
-}
-func TableCreatePath(msgs []*ProcessMessage) []Path {
pathT := make([]Path, 3)
- for i, msg := range msgs {
- updateMsgT := msg.innerMessage.Body.(*bgp.BGPUpdate)
+ for i, msg := range []*bgp.BGPMessage{bgpMsgT1, bgpMsgT2, bgpMsgT3} {
+ updateMsgT := msg.Body.(*bgp.BGPUpdate)
nlriList := updateMsgT.NLRI
pathAttributes := updateMsgT.PathAttributes
nlri_info := nlriList[0]
- pathT[i], _ = CreatePath(msg.fromPeer, &nlri_info, pathAttributes, false, time.Now())
+ pathT[i], _ = CreatePath(peerT[i], &nlri_info, pathAttributes, false, time.Now())
}
return pathT
}