diff --git a/.gitignore b/.gitignore index c16085f..653cb5a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ birdwatcher-* DIST/ *.local.* +debug.test \ No newline at end of file diff --git a/bird/parser_test.go b/bird/parser_test.go index f394c46..20e8bc7 100644 --- a/bird/parser_test.go +++ b/bird/parser_test.go @@ -40,8 +40,16 @@ func TestParseBgpRoutes(t *testing.T) { } -func TestParseRoutesAll(t *testing.T) { - f, err := openFile("routes_bird1_ipv4.sample") +func TestParseRoutesAllIpv4Bird1(t *testing.T) { + runTestForIpv4WithFile("routes_bird1_ipv4.sample", t) +} + +func TestParseRoutesAllIpv4Bird2(t *testing.T) { + runTestForIpv4WithFile("routes_bird2_ipv4.sample", t) +} + +func runTestForIpv4WithFile(file string, t *testing.T) { + f, err := openFile(file) if err != nil { t.Error(err) } @@ -50,7 +58,7 @@ func TestParseRoutesAll(t *testing.T) { result := parseRoutes(f) routes, ok := result["routes"].([]Parsed) if !ok { - t.Error("Error getting routes") + t.Fatal("Error getting routes") } if len(routes) != 4 { @@ -127,15 +135,15 @@ func TestParseRoutesAll(t *testing.T) { }, routes[3], "Route 4", t) } -func TestParseRoutesAllBird1(t *testing.T) { - runTestForIpv6WithTemplate("routes_bird1_ipv6.sample", t) +func TestParseRoutesAllIpv6Bird1(t *testing.T) { + runTestForIpv6WithFile("routes_bird1_ipv6.sample", t) } -func TestParseRoutesAllBird2(t *testing.T) { - runTestForIpv6WithTemplate("routes_bird2_ipv6.sample", t) +func TestParseRoutesAllIpv6Bird2(t *testing.T) { + runTestForIpv6WithFile("routes_bird2_ipv6.sample", t) } -func runTestForIpv6WithTemplate(file string, t *testing.T) { +func runTestForIpv6WithFile(file string, t *testing.T) { f, err := openFile(file) if err != nil { t.Error(err) diff --git a/test/routes_bird2_ipv4.sample b/test/routes_bird2_ipv4.sample new file mode 100644 index 0000000..ee337f3 --- /dev/null +++ b/test/routes_bird2_ipv4.sample @@ -0,0 +1,37 @@ +BIRD 1.6.3 ready. +16.0.0.0/24 unicast [ID8503_AS1340 2017-06-21 08:17:33] * (100) [AS1340i] + via 1.2.3.16 on eno7 + Type: BGP univ + BGP.origin: IGP + BGP.as_path: 1340 + BGP.next_hop: 1.2.3.16 + BGP.local_pref: 100 + BGP.community: (65011,3) (9033,3251) + BGP.large_community: (9033, 65666, 12) (9033, 65666, 9) +200.0.0.0/24 unicast [ID8497_AS1339 2017-06-21 08:17:31] * (100) [AS1339i] + via 1.2.3.15 on eno7 + Type: BGP univ + BGP.origin: IGP + BGP.as_path: 1339 + BGP.next_hop: 1.2.3.15 + BGP.local_pref: 100 + BGP.community: (65011,40) (9033,3251) + BGP.large_community: (9033, 65666, 12) (9033, 65666, 9) + unicast [ID8503_AS1340 2017-06-21 08:17:33] (100/?) [AS1340i] + via 1.2.3.16 on eno7 + Type: BGP univ + BGP.origin: IGP + BGP.as_path: 1340 + BGP.next_hop: 1.2.3.16 + BGP.local_pref: 100 + BGP.community: (65011,3) (9033,3251) + BGP.large_community: (9033, 65666, 12) (9033, 65666, 9) +16.0.0.0/24 unicast [ID8503_AS1340 2017-06-21 08:17:33] * (100) [AS1340i] + via 1.2.3.16 on eno7 [ + Type: BGP univ + BGP.origin: IGP + BGP.as_path: 1340 + BGP.next_hop: 1.2.3.16 + BGP.local_pref: 100 + BGP.community: (65011,3) (9033,3251) + BGP.large_community: (9033, 65666, 12) (9033, 65666, 9)