Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
bio-rd
Commits
80ad835f
Commit
80ad835f
authored
6 years ago
by
Daniel Czerwonk
Browse files
Options
Downloads
Patches
Plain Diff
resored filter tests
parent
9b2f55a0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
routingtable/filter/filter_test.go
+17
-92
17 additions, 92 deletions
routingtable/filter/filter_test.go
with
17 additions
and
92 deletions
routingtable/filter/filter_test.go
+
17
−
92
View file @
80ad835f
package
filter
package
filter
/*func TestAddPath(t *testing.T) {
import
(
tests := []struct {
"testing"
name string
prefix net.Prefix
path *route.Path
term *Term
exptectCalled bool
expectModified bool
}{
{
name: "accept",
prefix: net.NewPfx(0, 0),
path: &route.Path{},
term: &Term{
then: []FilterAction{
&actions.AcceptAction{},
},
},
exptectCalled: true,
expectModified: false,
},
{
name: "reject",
prefix: net.NewPfx(0, 0),
path: &route.Path{},
term: &Term{
then: []FilterAction{
&actions.RejectAction{},
},
},
exptectCalled: false,
expectModified: false,
},
{
name: "modified",
prefix: net.NewPfx(0, 0),
path: &route.Path{},
term: &Term{
then: []FilterAction{
&mockAction{},
&actions.AcceptAction{},
},
},
exptectCalled: true,
expectModified: true,
},
}
for _, test := range tests {
t.Run(test.name, func(te *testing.T) {
m := newClientMock()
f := NewFilter([]*Term{test.term})
f.Register(m)
f.AddPath(test.prefix, test.path)
"github.com/bio-routing/bio-rd/net"
assert.Equal(te, test.exptectCalled, m.addPathCalled, "called")
"github.com/bio-routing/bio-rd/route"
"github.com/bio-routing/bio-rd/routingtable/filter/actions"
"github.com/stretchr/testify/assert"
)
if !test.exptectCalled {
func
TestProcessTerms
(
t
*
testing
.
T
)
{
return
}
if m.path != test.path && !test.expectModified {
te.Fatal("expected path to be not modified but was")
}
if m.path == test.path && test.expectModified {
te.Fatal("expected path to be modified but was same reference")
}
})
}
}
func TestRemovePath(t *testing.T) {
tests
:=
[]
struct
{
tests
:=
[]
struct
{
name
string
name
string
prefix
net
.
Prefix
prefix
net
.
Prefix
path
*
route
.
Path
path
*
route
.
Path
term
*
Term
term
*
Term
exptect
Called
bool
exptect
Accept
bool
expectModified
bool
expectModified
bool
}{
}{
{
{
...
@@ -91,7 +27,7 @@ func TestRemovePath(t *testing.T) {
...
@@ -91,7 +27,7 @@ func TestRemovePath(t *testing.T) {
&
actions
.
AcceptAction
{},
&
actions
.
AcceptAction
{},
},
},
},
},
exptect
Called
: true,
exptect
Accept
:
true
,
expectModified
:
false
,
expectModified
:
false
,
},
},
{
{
...
@@ -103,7 +39,7 @@ func TestRemovePath(t *testing.T) {
...
@@ -103,7 +39,7 @@ func TestRemovePath(t *testing.T) {
&
actions
.
RejectAction
{},
&
actions
.
RejectAction
{},
},
},
},
},
exptect
Called
: false,
exptect
Accept
:
false
,
expectModified
:
false
,
expectModified
:
false
,
},
},
{
{
...
@@ -116,32 +52,21 @@ func TestRemovePath(t *testing.T) {
...
@@ -116,32 +52,21 @@ func TestRemovePath(t *testing.T) {
&
actions
.
AcceptAction
{},
&
actions
.
AcceptAction
{},
},
},
},
},
exptect
Called
: true,
exptect
Accept
:
true
,
expectModified
:
true
,
expectModified
:
true
,
},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
te
*
testing
.
T
)
{
t
.
Run
(
test
.
name
,
func
(
te
*
testing
.
T
)
{
m := newClientMock()
f
:=
NewFilter
([]
*
Term
{
test
.
term
})
f
:=
NewFilter
([]
*
Term
{
test
.
term
})
f.Register(m
)
p
,
reject
:=
f
.
ProcessTerms
(
test
.
prefix
,
test
.
path
)
f.RemovePath(test.prefix, test.path)
assert
.
Equal
(
t
,
test
.
exptectAccept
,
!
reject
)
assert.Equal(te, test.exptectCalled, m.removePathCalled, "called")
if !test.exptectCalled {
return
}
if m.path != test.path && !test.expectModified {
if
test
.
expectModified
{
te.Fatal("expected path to be not modified but was")
assert
.
NotEqual
(
t
,
test
.
path
,
p
)
}
if m.path == test.path && test.expectModified {
te.Fatal("expected path to be modified but was same reference")
}
}
})
})
}
}
}
*/
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment