diff options
author | Wolfy-J <[email protected]> | 2018-09-10 16:42:15 +0400 |
---|---|---|
committer | GitHub <[email protected]> | 2018-09-10 16:42:15 +0400 |
commit | a554a98dda0d793da09db17314ef3977a2f3a465 (patch) | |
tree | 64b506898d283c39babc48da5a29df203cb57b49 /service/http/handler_test.go | |
parent | ea97c188a4a74c00b585cb50fa1ed4db7d190e09 (diff) | |
parent | 46a06a4d104802fb4271e06da487f74f23edd10c (diff) |
Merge pull request #33 from spiral/feature/env-setterv1.2.0
Feature/env setter
Diffstat (limited to 'service/http/handler_test.go')
-rw-r--r-- | service/http/handler_test.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/service/http/handler_test.go b/service/http/handler_test.go index 59a4c7c0..b82fc938 100644 --- a/service/http/handler_test.go +++ b/service/http/handler_test.go @@ -14,6 +14,7 @@ import ( "strings" "testing" "time" + "net/http/httptest" ) // get request and return body @@ -63,6 +64,63 @@ func TestServer_Echo(t *testing.T) { assert.Equal(t, "WORLD", body) } +func Test_HandlerErrors(t *testing.T) { + st := &Handler{ + cfg: &Config{ + MaxRequest: 1024, + Uploads: &UploadsConfig{ + Dir: os.TempDir(), + Forbid: []string{}, + }, + }, + rr: roadrunner.NewServer(&roadrunner.ServerConfig{ + Command: "php ../../php-src/tests/http/client.php echo pipes", + Relay: "pipes", + Pool: &roadrunner.Config{ + NumWorkers: 1, + AllocateTimeout: 10000000, + DestroyTimeout: 10000000, + }, + }), + } + + wr := httptest.NewRecorder() + rq := httptest.NewRequest("POST", "/", bytes.NewBuffer([]byte("data"))) + + st.ServeHTTP(wr, rq) + assert.Equal(t, 500, wr.Code) +} + +func Test_Handler_JSON_error(t *testing.T) { + st := &Handler{ + cfg: &Config{ + MaxRequest: 1024, + Uploads: &UploadsConfig{ + Dir: os.TempDir(), + Forbid: []string{}, + }, + }, + rr: roadrunner.NewServer(&roadrunner.ServerConfig{ + Command: "php ../../php-src/tests/http/client.php echo pipes", + Relay: "pipes", + Pool: &roadrunner.Config{ + NumWorkers: 1, + AllocateTimeout: 10000000, + DestroyTimeout: 10000000, + }, + }), + } + + wr := httptest.NewRecorder() + rq := httptest.NewRequest("POST", "/", bytes.NewBuffer([]byte("{sd"))) + rq.Header.Add("Content-Type","application/json") + rq.Header.Add("Content-Size","3") + + st.ServeHTTP(wr, rq) + assert.Equal(t, 500, wr.Code) +} + + func TestServer_Headers(t *testing.T) { st := &Handler{ cfg: &Config{ |