diff options
-rw-r--r-- | service/http/ssl_test.go | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/service/http/ssl_test.go b/service/http/ssl_test.go index b82aa75c..c650a266 100644 --- a/service/http/ssl_test.go +++ b/service/http/ssl_test.go @@ -53,20 +53,13 @@ func Test_SSL_Service_Echo(t *testing.T) { t.Errorf("error during the Serve: error %v", err) } }() - time.Sleep(time.Millisecond * 100) - defer c.Stop() + time.Sleep(time.Millisecond * 500) req, err := http.NewRequest("GET", "https://localhost:6900?hello=world", nil) assert.NoError(t, err) r, err := sslClient.Do(req) assert.NoError(t, err) - defer func() { - err := r.Body.Close() - if err != nil { - t.Errorf("fail to close the Body: error %v", err) - } - }() b, err := ioutil.ReadAll(r.Body) assert.NoError(t, err) @@ -74,6 +67,13 @@ func Test_SSL_Service_Echo(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 201, r.StatusCode) assert.Equal(t, "WORLD", string(b)) + + err2 := r.Body.Close() + if err2 != nil { + t.Errorf("fail to close the Body: error %v", err2) + } + + c.Stop() } func Test_SSL_Service_NoRedirect(t *testing.T) { @@ -110,16 +110,13 @@ func Test_SSL_Service_NoRedirect(t *testing.T) { } }() - time.Sleep(time.Second) + time.Sleep(time.Millisecond * 500) req, err := http.NewRequest("GET", "http://localhost:6030?hello=world", nil) assert.NoError(t, err) r, err := sslClient.Do(req) assert.NoError(t, err) - defer func() { - - }() assert.Nil(t, r.TLS) @@ -172,17 +169,13 @@ func Test_SSL_Service_Redirect(t *testing.T) { } }() - time.Sleep(time.Second) + time.Sleep(time.Millisecond * 500) req, err := http.NewRequest("GET", "http://localhost:6031?hello=world", nil) assert.NoError(t, err) r, err := sslClient.Do(req) assert.NoError(t, err) - defer func() { - - }() - assert.NotNil(t, r.TLS) b, err := ioutil.ReadAll(r.Body) @@ -233,20 +226,13 @@ func Test_SSL_Service_Push(t *testing.T) { t.Errorf("error during the Serve: error %v", err) } }() - time.Sleep(time.Millisecond * 100) - defer c.Stop() + time.Sleep(time.Millisecond * 500) req, err := http.NewRequest("GET", "https://localhost:6903?hello=world", nil) assert.NoError(t, err) r, err := sslClient.Do(req) assert.NoError(t, err) - defer func() { - err := r.Body.Close() - if err != nil { - t.Errorf("fail to close the Body: error %v", err) - } - }() assert.NotNil(t, r.TLS) @@ -258,4 +244,11 @@ func Test_SSL_Service_Push(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 201, r.StatusCode) assert.Equal(t, "WORLD", string(b)) + + + err2 := r.Body.Close() + if err2 != nil { + t.Errorf("fail to close the Body: error %v", err2) + } + c.Stop() } |