diff options
author | Valery Piashchynski <[email protected]> | 2020-03-03 19:58:37 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-03-03 19:58:37 +0300 |
commit | 082d49a7c9825038b587d3333a09dab41025a138 (patch) | |
tree | b8cf0f38029ba9fdb234bfed273c47b77ad7a12e /service/http | |
parent | 63de1b8cb47332a2d3f0cf560940cb78c08d6e6e (diff) |
ssl defers update
Diffstat (limited to 'service/http')
-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() } |