Manager: rename assertXXXResponse to assertResponseXXX

Rename test functions like `assertJSONResponse` to `assertResponseJSON`,
so that they get ordered together by autocompletion.

No functional changes.
This commit is contained in:
Sybren A. Stüvel 2022-04-21 12:01:37 +02:00
parent c3b694ab2a
commit 954af37fd5
3 changed files with 9 additions and 9 deletions

View File

@ -161,7 +161,7 @@ func TestGetJobTypeHappy(t *testing.T) {
err := mf.flamenco.GetJobType(echoCtx, "test-job-type") err := mf.flamenco.GetJobType(echoCtx, "test-job-type")
assert.NoError(t, err) assert.NoError(t, err)
assertJSONResponse(t, echoCtx, http.StatusOK, jt) assertResponseJSON(t, echoCtx, http.StatusOK, jt)
} }
func TestGetJobTypeUnknown(t *testing.T) { func TestGetJobTypeUnknown(t *testing.T) {
@ -176,7 +176,7 @@ func TestGetJobTypeUnknown(t *testing.T) {
echoCtx := mf.prepareMockedRequest(nil) echoCtx := mf.prepareMockedRequest(nil)
err := mf.flamenco.GetJobType(echoCtx, "nonexistent-type") err := mf.flamenco.GetJobType(echoCtx, "nonexistent-type")
assert.NoError(t, err) assert.NoError(t, err)
assertJSONResponse(t, echoCtx, http.StatusNotFound, api.Error{ assertResponseJSON(t, echoCtx, http.StatusNotFound, api.Error{
Code: http.StatusNotFound, Code: http.StatusNotFound,
Message: "no such job type known", Message: "no such job type known",
}) })
@ -193,5 +193,5 @@ func TestGetJobTypeError(t *testing.T) {
echoCtx := mf.prepareMockedRequest(nil) echoCtx := mf.prepareMockedRequest(nil)
err := mf.flamenco.GetJobType(echoCtx, "error") err := mf.flamenco.GetJobType(echoCtx, "error")
assert.NoError(t, err) assert.NoError(t, err)
assertAPIErrorResponse(t, echoCtx, http.StatusInternalServerError, "error getting job type") assertResponseAPIError(t, echoCtx, http.StatusInternalServerError, "error getting job type")
} }

View File

@ -87,8 +87,8 @@ func getRecordedResponse(echoCtx echo.Context) *http.Response {
return resp.Result() return resp.Result()
} }
// assertJSONResponse asserts that a recorded response is JSON with the given HTTP status code. // assertResponseJSON asserts that a recorded response is JSON with the given HTTP status code.
func assertJSONResponse(t *testing.T, echoCtx echo.Context, expectStatusCode int, expectBody interface{}) { func assertResponseJSON(t *testing.T, echoCtx echo.Context, expectStatusCode int, expectBody interface{}) {
resp := getRecordedResponse(echoCtx) resp := getRecordedResponse(echoCtx)
assert.Equal(t, expectStatusCode, resp.StatusCode) assert.Equal(t, expectStatusCode, resp.StatusCode)
contentType := resp.Header.Get(echo.HeaderContentType) contentType := resp.Header.Get(echo.HeaderContentType)
@ -111,8 +111,8 @@ func assertJSONResponse(t *testing.T, echoCtx echo.Context, expectStatusCode int
assert.JSONEq(t, string(expectJSON), string(actualJSON)) assert.JSONEq(t, string(expectJSON), string(actualJSON))
} }
func assertAPIErrorResponse(t *testing.T, echoCtx echo.Context, expectStatusCode int, expectMessage string) { func assertResponseAPIError(t *testing.T, echoCtx echo.Context, expectStatusCode int, expectMessage string) {
assertJSONResponse(t, echoCtx, expectStatusCode, api.Error{ assertResponseJSON(t, echoCtx, expectStatusCode, api.Error{
Code: int32(expectStatusCode), Code: int32(expectStatusCode),
Message: expectMessage, Message: expectMessage,
}) })

View File

@ -43,7 +43,7 @@ func TestTaskScheduleHappy(t *testing.T) {
Job: job.UUID, Job: job.UUID,
Commands: []api.Command{}, Commands: []api.Command{},
} }
assertJSONResponse(t, echo, http.StatusOK, assignedTask) assertResponseJSON(t, echo, http.StatusOK, assignedTask)
resp := getRecordedResponse(echo) resp := getRecordedResponse(echo)
assert.Equal(t, http.StatusOK, resp.StatusCode) assert.Equal(t, http.StatusOK, resp.StatusCode)
} }
@ -85,7 +85,7 @@ func TestTaskScheduleOtherStatusRequested(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
expectBody := api.WorkerStateChange{StatusRequested: api.WorkerStatusAsleep} expectBody := api.WorkerStateChange{StatusRequested: api.WorkerStatusAsleep}
assertJSONResponse(t, echoCtx, http.StatusLocked, expectBody) assertResponseJSON(t, echoCtx, http.StatusLocked, expectBody)
} }
func TestWorkerSignoffTaskRequeue(t *testing.T) { func TestWorkerSignoffTaskRequeue(t *testing.T) {