Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix failing router tests #360

Merged
merged 2 commits into from
Feb 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/httpapi/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package httpapi

import "fmt"

// Response is a generic response object from Configuration and Events API.
type Response struct {
Errors []Error `json:"errors"`
}
Expand Down
10 changes: 5 additions & 5 deletions router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestRouterServeHTTP_StatusUnavailableWhenDraining(t *testing.T) {
router.ServeHTTP(recorder, req)

assert.Equal(t, http.StatusServiceUnavailable, recorder.Code)
assert.Equal(t, "Service Unavailable\n", recorder.Body.String())
assert.Equal(t, `{"errors":[{"message":"Service Unavailable"}]}`+"\n", recorder.Body.String())
}

func TestRouterServeHTTP_HTTPEventFunctionNotFound(t *testing.T) {
Expand All @@ -46,7 +46,7 @@ func TestRouterServeHTTP_HTTPEventFunctionNotFound(t *testing.T) {
router.ServeHTTP(recorder, req)

assert.Equal(t, http.StatusNotFound, recorder.Code)
assert.Equal(t, "resource not found\n", recorder.Body.String())
assert.Equal(t, `{"errors":[{"message":"resource not found"}]}`+"\n", recorder.Body.String())
}

func TestRouterServeHTTP_InvokeEventFunctionNotFound(t *testing.T) {
Expand All @@ -65,7 +65,7 @@ func TestRouterServeHTTP_InvokeEventFunctionNotFound(t *testing.T) {
router.ServeHTTP(recorder, req)

assert.Equal(t, http.StatusInternalServerError, recorder.Code)
assert.Equal(t, "unable to look up registered function\n", recorder.Body.String())
assert.Equal(t, `{"errors":[{"message":"unable to look up registered function"}]}`+"\n", recorder.Body.String())
}

func TestRouterServeHTTP_ErrorMalformedCustomEventJSONRequest(t *testing.T) {
Expand All @@ -80,7 +80,7 @@ func TestRouterServeHTTP_ErrorMalformedCustomEventJSONRequest(t *testing.T) {
router.ServeHTTP(recorder, req)

assert.Equal(t, http.StatusBadRequest, recorder.Code)
assert.Equal(t, "malformed JSON body\n", recorder.Body.String())
assert.Equal(t, `{"errors":[{"message":"malformed JSON body"}]}`+"\n", recorder.Body.String())
}

func TestRouterServeHTTP_ErrorOnCustomEventEmittedWithNonPostMethod(t *testing.T) {
Expand All @@ -96,7 +96,7 @@ func TestRouterServeHTTP_ErrorOnCustomEventEmittedWithNonPostMethod(t *testing.T
router.ServeHTTP(recorder, req)

assert.Equal(t, http.StatusBadRequest, recorder.Code)
assert.Equal(t, "custom event can be emitted only with POST method\n", recorder.Body.String())
assert.Equal(t, `{"errors":[{"message":"custom event can be emitted only with POST method"}]}`+"\n", recorder.Body.String())
}

func TestRouterServeHTTP_AllowCORSPreflightForHTTPEventWhenConfigured(t *testing.T) {
Expand Down