TUN-814: Handle error in CreateTLSListener before closing listener

This commit is contained in:
Chung-Ting Huang 2018-07-25 09:07:27 -05:00
parent 0468866626
commit 7c084ad32b
1 changed files with 3 additions and 3 deletions

View File

@ -6,10 +6,10 @@ import (
func TestCreateTLSListenerHostAndPortSuccess(t *testing.T) {
listener, err := CreateTLSListener("localhost:1234")
defer listener.Close()
if err != nil {
t.Fatal(err)
}
defer listener.Close()
if listener.Addr().String() == "" {
t.Fatal("Fail to find available port")
}
@ -17,10 +17,10 @@ func TestCreateTLSListenerHostAndPortSuccess(t *testing.T) {
func TestCreateTLSListenerOnlyHostSuccess(t *testing.T) {
listener, err := CreateTLSListener("localhost:")
defer listener.Close()
if err != nil {
t.Fatal(err)
}
defer listener.Close()
if listener.Addr().String() == "" {
t.Fatal("Fail to find available port")
}
@ -28,10 +28,10 @@ func TestCreateTLSListenerOnlyHostSuccess(t *testing.T) {
func TestCreateTLSListenerOnlyPortSuccess(t *testing.T) {
listener, err := CreateTLSListener(":8888")
defer listener.Close()
if err != nil {
t.Fatal(err)
}
defer listener.Close()
if listener.Addr().String() == "" {
t.Fatal("Fail to find available port")
}