summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2020-10-20 14:38:03 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2020-10-20 15:36:19 +0900
commit22d745fcf591c2a14204598cb2b00877c7a9e3c6 (patch)
treec049167726445fdf28e78175096369ee8f19ab33 /pkg
parent98b017d1ade751b3c2323fbdebe631e3454ebde0 (diff)
server: fix ListPolicyAssignment to handle empty policy
fix ListPolicyAssignment() return an assignment response even if the response doesn't have any policy. The assignment has default action policy so it's useful without any policy. Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/server/server.go3
-rw-r--r--pkg/server/server_test.go6
2 files changed, 3 insertions, 6 deletions
diff --git a/pkg/server/server.go b/pkg/server/server.go
index 1b49880d..ef8bd3c8 100644
--- a/pkg/server/server.go
+++ b/pkg/server/server.go
@@ -3492,9 +3492,6 @@ func (s *BgpServer) ListPolicyAssignment(ctx context.Context, r *api.ListPolicyA
if err != nil {
return err
}
- if len(policies) == 0 {
- continue
- }
t := &table.PolicyAssignment{
Name: name,
Type: dir,
diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go
index 34e9be1f..6f70f38a 100644
--- a/pkg/server/server_test.go
+++ b/pkg/server/server_test.go
@@ -194,19 +194,19 @@ func TestListPolicyAssignment(t *testing.T) {
Name: table.GLOBAL_RIB_NAME,
}, func(p *api.PolicyAssignment) { ps = append(ps, p) })
assert.Nil(err)
- assert.Equal(len(ps), 0)
+ assert.Equal(2, len(ps))
ps = []*api.PolicyAssignment{}
err = s.ListPolicyAssignment(context.Background(), &api.ListPolicyAssignmentRequest{}, func(p *api.PolicyAssignment) { ps = append(ps, p) })
assert.Nil(err)
- assert.Equal(len(ps), 3)
+ assert.Equal(8, len(ps))
ps = []*api.PolicyAssignment{}
err = s.ListPolicyAssignment(context.Background(), &api.ListPolicyAssignmentRequest{
Direction: api.PolicyDirection_EXPORT,
}, func(p *api.PolicyAssignment) { ps = append(ps, p) })
assert.Nil(err)
- assert.Equal(len(ps), 0)
+ assert.Equal(4, len(ps))
}
func TestListPathEnableFiltered(test *testing.T) {