diff options
author | Matt Holt <mholt@users.noreply.github.com> | 2022-08-03 11:04:51 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-03 11:04:51 -0600 |
commit | 1960a0dc117dd30fb507b390ddf93b2ef371b9ad (patch) | |
tree | 42837b24d53dd449ac153d7b1d252ee8422e4729 /listeners_test.go | |
parent | 63c7720e84176184698730fed0ca7c402c53481a (diff) |
httpserver: Configurable shutdown delay (#4906)
Diffstat (limited to 'listeners_test.go')
-rw-r--r-- | listeners_test.go | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/listeners_test.go b/listeners_test.go index 6b0f440..c5aa527 100644 --- a/listeners_test.go +++ b/listeners_test.go @@ -331,3 +331,85 @@ func TestJoinHostPort(t *testing.T) { } } } + +func TestExpand(t *testing.T) { + for i, tc := range []struct { + input NetworkAddress + expect []NetworkAddress + }{ + { + input: NetworkAddress{ + Network: "tcp", + Host: "localhost", + StartPort: 2000, + EndPort: 2000, + }, + expect: []NetworkAddress{ + { + Network: "tcp", + Host: "localhost", + StartPort: 2000, + EndPort: 2000, + }, + }, + }, + { + input: NetworkAddress{ + Network: "tcp", + Host: "localhost", + StartPort: 2000, + EndPort: 2002, + }, + expect: []NetworkAddress{ + { + Network: "tcp", + Host: "localhost", + StartPort: 2000, + EndPort: 2000, + }, + { + Network: "tcp", + Host: "localhost", + StartPort: 2001, + EndPort: 2001, + }, + { + Network: "tcp", + Host: "localhost", + StartPort: 2002, + EndPort: 2002, + }, + }, + }, + { + input: NetworkAddress{ + Network: "tcp", + Host: "localhost", + StartPort: 2000, + EndPort: 1999, + }, + expect: []NetworkAddress{}, + }, + { + input: NetworkAddress{ + Network: "unix", + Host: "/foo/bar", + StartPort: 0, + EndPort: 0, + }, + expect: []NetworkAddress{ + { + Network: "unix", + Host: "/foo/bar", + StartPort: 0, + EndPort: 0, + }, + }, + }, + } { + actual := tc.input.Expand() + if !reflect.DeepEqual(actual, tc.expect) { + t.Errorf("Test %d: Expected %+v but got %+v", i, tc.expect, actual) + } + } +} |