diff options
author | Wolfy-J <[email protected]> | 2018-06-13 14:02:14 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-13 14:02:14 +0300 |
commit | b58bbaa615f38916860e06db27e2ab31b0eb2d08 (patch) | |
tree | 8e446b203dd3c2ab47147a6efd864416a88af841 /service/http/handler_test.go | |
parent | 8b24183daa620bb12edf78f6e81697532cbc92d8 (diff) |
more tests for files!
Diffstat (limited to 'service/http/handler_test.go')
-rw-r--r-- | service/http/handler_test.go | 62 |
1 files changed, 15 insertions, 47 deletions
diff --git a/service/http/handler_test.go b/service/http/handler_test.go index 560b9c1b..6cc9aeb1 100644 --- a/service/http/handler_test.go +++ b/service/http/handler_test.go @@ -229,16 +229,12 @@ func TestServer_JsonPayload_PUT(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8081", Handler: st,} + hs := &http.Server{Addr: ":8081", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() - req, err := http.NewRequest( - "PUT", - "http://localhost"+hs.Addr, - bytes.NewBufferString(`{"key":"value"}`), - ) + req, err := http.NewRequest("PUT", "http://localhost"+hs.Addr, bytes.NewBufferString(`{"key":"value"}`)) assert.NoError(t, err) req.Header.Add("Content-Type", "application/json") @@ -278,17 +274,13 @@ func TestServer_JsonPayload_PATCH(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8082", Handler: st,} + hs := &http.Server{Addr: ":8082", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() time.Sleep(time.Millisecond * 10) - req, err := http.NewRequest( - "PATCH", - "http://localhost"+hs.Addr, - bytes.NewBufferString(`{"key":"value"}`), - ) + req, err := http.NewRequest("PATCH", "http://localhost"+hs.Addr, bytes.NewBufferString(`{"key":"value"}`)) assert.NoError(t, err) req.Header.Add("Content-Type", "application/json") @@ -345,11 +337,7 @@ func TestServer_FormData_POST(t *testing.T) { form.Add("arr[c]p", "l") form.Add("arr[c]z", "") - req, err := http.NewRequest( - "POST", - "http://localhost"+hs.Addr, - strings.NewReader(form.Encode()), - ) + req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, strings.NewReader(form.Encode())) assert.NoError(t, err) req.Header.Add("Content-Type", "application/x-www-form-urlencoded") @@ -390,7 +378,7 @@ func TestServer_FormData_PUT(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8084", Handler: st,} + hs := &http.Server{Addr: ":8084", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() @@ -407,11 +395,7 @@ func TestServer_FormData_PUT(t *testing.T) { form.Add("arr[c]p", "l") form.Add("arr[c]z", "") - req, err := http.NewRequest( - "PUT", - "http://localhost"+hs.Addr, - strings.NewReader(form.Encode()), - ) + req, err := http.NewRequest("PUT", "http://localhost"+hs.Addr, strings.NewReader(form.Encode())) assert.NoError(t, err) req.Header.Add("Content-Type", "application/x-www-form-urlencoded") @@ -452,7 +436,7 @@ func TestServer_FormData_PATCH(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8085", Handler: st,} + hs := &http.Server{Addr: ":8085", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() @@ -469,11 +453,7 @@ func TestServer_FormData_PATCH(t *testing.T) { form.Add("arr[c]p", "l") form.Add("arr[c]z", "") - req, err := http.NewRequest( - "PATCH", - "http://localhost"+hs.Addr, - strings.NewReader(form.Encode()), - ) + req, err := http.NewRequest("PATCH", "http://localhost"+hs.Addr, strings.NewReader(form.Encode())) assert.NoError(t, err) req.Header.Add("Content-Type", "application/x-www-form-urlencoded") @@ -514,7 +494,7 @@ func TestServer_Multipart_POST(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8019", Handler: st,} + hs := &http.Server{Addr: ":8019", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() @@ -535,11 +515,7 @@ func TestServer_Multipart_POST(t *testing.T) { w.Close() - req, err := http.NewRequest( - "POST", - "http://localhost"+hs.Addr, - &mb, - ) + req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, &mb) assert.NoError(t, err) req.Header.Set("Content-Type", w.FormDataContentType()) @@ -580,7 +556,7 @@ func TestServer_Multipart_PUT(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8020", Handler: st,} + hs := &http.Server{Addr: ":8020", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() @@ -601,11 +577,7 @@ func TestServer_Multipart_PUT(t *testing.T) { w.Close() - req, err := http.NewRequest( - "PUT", - "http://localhost"+hs.Addr, - &mb, - ) + req, err := http.NewRequest("PUT", "http://localhost"+hs.Addr, &mb) assert.NoError(t, err) req.Header.Set("Content-Type", w.FormDataContentType()) @@ -646,7 +618,7 @@ func TestServer_Multipart_PATCH(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8021", Handler: st,} + hs := &http.Server{Addr: ":8021", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() @@ -667,11 +639,7 @@ func TestServer_Multipart_PATCH(t *testing.T) { w.Close() - req, err := http.NewRequest( - "PATCH", - "http://localhost"+hs.Addr, - &mb, - ) + req, err := http.NewRequest("PATCH", "http://localhost"+hs.Addr, &mb) assert.NoError(t, err) req.Header.Set("Content-Type", w.FormDataContentType()) |