summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/table/policy_test.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-08-16 22:58:22 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-08-16 22:58:22 +0900
commitf0b724878360618dd0a950364709b048486771b6 (patch)
tree9b382035c4b759bd1567436e11ab0b91ff062d10 /internal/pkg/table/policy_test.go
parent0b6486f34ccbb16962ecd3d73e08a85c57fadde7 (diff)
pkt/server: ListPolicy() and ListStatement() support filtering like ListDefinedSet() and ListPolicyAassignment()
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'internal/pkg/table/policy_test.go')
-rw-r--r--internal/pkg/table/policy_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/pkg/table/policy_test.go b/internal/pkg/table/policy_test.go
index 7f1a1dd9..31889980 100644
--- a/internal/pkg/table/policy_test.go
+++ b/internal/pkg/table/policy_test.go
@@ -32,6 +32,23 @@ import (
"github.com/stretchr/testify/require"
)
+func TestGetStatement(t *testing.T) {
+ r := NewRoutingPolicy()
+ r.statementMap["statement1"] = &Statement{Name: "statement1"}
+ r.statementMap["statement2"] = &Statement{Name: "statement2"}
+ assert.Equal(t, len(r.GetStatement("")), 2)
+ assert.Equal(t, len(r.GetStatement("statement1")), 1)
+ assert.Equal(t, len(r.GetStatement("unknown")), 0)
+}
+
+func TestGetPolicy(t *testing.T) {
+ r := NewRoutingPolicy()
+ r.policyMap["p1"] = &Policy{Name: "p1"}
+ r.policyMap["p2"] = &Policy{Name: "p2"}
+ assert.Equal(t, len(r.GetPolicy("")), 2)
+ assert.Equal(t, len(r.GetPolicy("p1")), 1)
+ assert.Equal(t, len(r.GetPolicy("unknown")), 0)
+}
func TestPrefixCalcurateNoRange(t *testing.T) {
// create path
peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")}