Skip to content

Commit

Permalink
template: Add unit tests for clipHAProxyTimeoutValue(...)
Browse files Browse the repository at this point in the history
Add a unit test for clipHAProxyTimeoutValue(...) to
pkg/router/template/template_helper_test.go
  • Loading branch information
sgreene570 committed Oct 9, 2020
1 parent 701bc83 commit 2847d9f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pkg/router/template/template_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,3 +767,33 @@ func TestProcessEndpointsForAlias(t *testing.T) {
router.DeleteEndpoints(suKey)
}
}

func TestClipHAProxyTimeoutValue(t *testing.T) {
testCases := []struct {
value string
expected string
}{
{
value: "10s",
expected: "10s",
},
{
value: "10d",
expected: "10d",
},
{
value: "100d",
expected: haproxyMaxTimeout,
},
{
value: "1000h",
expected: haproxyMaxTimeout,
},
}
for _, tc := range testCases {
actual := clipHAProxyTimeoutValue(tc.value)
if actual != tc.expected {
t.Errorf("clipHAProxyTimeoutValue yielded incorrect result: expected %s but got %s", tc.expected, actual)
}
}
}

0 comments on commit 2847d9f

Please sign in to comment.