Skip to content
Snippets Groups Projects
Commit 43bc032f authored by Oliver Herms's avatar Oliver Herms
Browse files

Fixing path selection

parent 8dd06f05
Branches
Tags
No related merge requests found
......@@ -116,7 +116,7 @@ func getBestProtocol(paths []*Path) uint8 {
continue
}
if p.Type > best {
if p.Type < best {
best = p.Type
}
}
......
......@@ -367,3 +367,29 @@ func TestAddPaths(t *testing.T) {
assert.Equal(t, test.expected, test.route)
}
}
func TestGetBestProtocol(t *testing.T) {
tests := []struct {
name string
input []*Path
expected uint8
}{
{
name: "Foo",
input: []*Path{
{
Type: BGPPathType,
},
{
Type: StaticPathType,
},
},
expected: StaticPathType,
},
}
for _, test := range tests {
res := getBestProtocol(test.input)
assert.Equal(t, test.expected, res)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment