From 24e397b0f65b1c5294ea711a953501fda944411d Mon Sep 17 00:00:00 2001 From: Wataru Ishida Date: Thu, 17 Nov 2016 02:06:22 -0500 Subject: add go vet test Signed-off-by: Wataru Ishida --- table/adj.go | 2 +- table/policy.go | 12 ++++++++++++ table/policy_test.go | 22 +++++++++++----------- 3 files changed, 24 insertions(+), 12 deletions(-) (limited to 'table') diff --git a/table/adj.go b/table/adj.go index ea7b4151..f1843859 100644 --- a/table/adj.go +++ b/table/adj.go @@ -192,7 +192,7 @@ func (adj *AdjRib) Select(family bgp.RouteFamily, accepted bool, option ...Table func (adj *AdjRib) TableInfo(family bgp.RouteFamily) (*TableInfo, error) { if _, ok := adj.table[family]; !ok { - return nil, fmt.Errorf("%s unsupported") + return nil, fmt.Errorf("%s unsupported", family) } c := adj.Count([]bgp.RouteFamily{family}) a := adj.Accepted([]bgp.RouteFamily{family}) diff --git a/table/policy.go b/table/policy.go index 7ac8a6c3..1d055b57 100644 --- a/table/policy.go +++ b/table/policy.go @@ -56,6 +56,18 @@ const ( ROUTE_TYPE_REJECT ) +func (t RouteType) String() string { + switch t { + case ROUTE_TYPE_NONE: + return "continue" + case ROUTE_TYPE_ACCEPT: + return "accept" + case ROUTE_TYPE_REJECT: + return "reject" + } + return fmt.Sprintf("unknown(%d)", t) +} + type PolicyDirection int const ( diff --git a/table/policy_test.go b/table/policy_test.go index 58b944e2..c3a04433 100644 --- a/table/policy_test.go +++ b/table/policy_test.go @@ -2862,8 +2862,8 @@ func TestPrefixSetMatch(t *testing.T) { func TestLargeCommunityMatchAction(t *testing.T) { coms := []*bgp.LargeCommunity{ - &bgp.LargeCommunity{100, 100, 100}, - &bgp.LargeCommunity{100, 200, 200}, + &bgp.LargeCommunity{ASN: 100, LocalData1: 100, LocalData2: 100}, + &bgp.LargeCommunity{ASN: 100, LocalData1: 200, LocalData2: 200}, } p := NewPath(nil, nil, false, []bgp.PathAttributeInterface{bgp.NewPathAttributeLargeCommunities(coms)}, time.Time{}, false) @@ -2887,10 +2887,10 @@ func TestLargeCommunityMatchAction(t *testing.T) { assert.Equal(t, m.Evaluate(p, nil), true) a, err := NewLargeCommunityAction(config.SetLargeCommunity{ - config.SetLargeCommunityMethod{ - []string{"100:100:100"}, + SetLargeCommunityMethod: config.SetLargeCommunityMethod{ + CommunitiesList: []string{"100:100:100"}, }, - config.BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE, + Options: config.BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE, }) assert.Equal(t, err, nil) p = a.Apply(p, nil) @@ -2898,13 +2898,13 @@ func TestLargeCommunityMatchAction(t *testing.T) { assert.Equal(t, m.Evaluate(p, nil), false) a, err = NewLargeCommunityAction(config.SetLargeCommunity{ - config.SetLargeCommunityMethod{ - []string{ + SetLargeCommunityMethod: config.SetLargeCommunityMethod{ + CommunitiesList: []string{ "100:300:100", "200:100:100", }, }, - config.BGP_SET_COMMUNITY_OPTION_TYPE_ADD, + Options: config.BGP_SET_COMMUNITY_OPTION_TYPE_ADD, }) assert.Equal(t, err, nil) p = a.Apply(p, nil) @@ -2912,10 +2912,10 @@ func TestLargeCommunityMatchAction(t *testing.T) { assert.Equal(t, m.Evaluate(p, nil), true) a, err = NewLargeCommunityAction(config.SetLargeCommunity{ - config.SetLargeCommunityMethod{ - []string{"^100:"}, + SetLargeCommunityMethod: config.SetLargeCommunityMethod{ + CommunitiesList: []string{"^100:"}, }, - config.BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE, + Options: config.BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE, }) assert.Equal(t, err, nil) p = a.Apply(p, nil) -- cgit v1.2.3