From 954af37fd5298f23879f5ba7ee7ae756c4c7234d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 21 Apr 2022 12:01:37 +0200 Subject: [PATCH] Manager: rename `assertXXXResponse` to `assertResponseXXX` Rename test functions like `assertJSONResponse` to `assertResponseJSON`, so that they get ordered together by autocompletion. No functional changes. --- internal/manager/api_impl/jobs_test.go | 6 +++--- internal/manager/api_impl/support_test.go | 8 ++++---- internal/manager/api_impl/workers_test.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/manager/api_impl/jobs_test.go b/internal/manager/api_impl/jobs_test.go index fc8a04dd..2ae59305 100644 --- a/internal/manager/api_impl/jobs_test.go +++ b/internal/manager/api_impl/jobs_test.go @@ -161,7 +161,7 @@ func TestGetJobTypeHappy(t *testing.T) { err := mf.flamenco.GetJobType(echoCtx, "test-job-type") assert.NoError(t, err) - assertJSONResponse(t, echoCtx, http.StatusOK, jt) + assertResponseJSON(t, echoCtx, http.StatusOK, jt) } func TestGetJobTypeUnknown(t *testing.T) { @@ -176,7 +176,7 @@ func TestGetJobTypeUnknown(t *testing.T) { echoCtx := mf.prepareMockedRequest(nil) err := mf.flamenco.GetJobType(echoCtx, "nonexistent-type") assert.NoError(t, err) - assertJSONResponse(t, echoCtx, http.StatusNotFound, api.Error{ + assertResponseJSON(t, echoCtx, http.StatusNotFound, api.Error{ Code: http.StatusNotFound, Message: "no such job type known", }) @@ -193,5 +193,5 @@ func TestGetJobTypeError(t *testing.T) { echoCtx := mf.prepareMockedRequest(nil) err := mf.flamenco.GetJobType(echoCtx, "error") assert.NoError(t, err) - assertAPIErrorResponse(t, echoCtx, http.StatusInternalServerError, "error getting job type") + assertResponseAPIError(t, echoCtx, http.StatusInternalServerError, "error getting job type") } diff --git a/internal/manager/api_impl/support_test.go b/internal/manager/api_impl/support_test.go index c6181aea..a69aa06a 100644 --- a/internal/manager/api_impl/support_test.go +++ b/internal/manager/api_impl/support_test.go @@ -87,8 +87,8 @@ func getRecordedResponse(echoCtx echo.Context) *http.Response { return resp.Result() } -// assertJSONResponse 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{}) { +// assertResponseJSON asserts that a recorded response is JSON with the given HTTP status code. +func assertResponseJSON(t *testing.T, echoCtx echo.Context, expectStatusCode int, expectBody interface{}) { resp := getRecordedResponse(echoCtx) assert.Equal(t, expectStatusCode, resp.StatusCode) 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)) } -func assertAPIErrorResponse(t *testing.T, echoCtx echo.Context, expectStatusCode int, expectMessage string) { - assertJSONResponse(t, echoCtx, expectStatusCode, api.Error{ +func assertResponseAPIError(t *testing.T, echoCtx echo.Context, expectStatusCode int, expectMessage string) { + assertResponseJSON(t, echoCtx, expectStatusCode, api.Error{ Code: int32(expectStatusCode), Message: expectMessage, }) diff --git a/internal/manager/api_impl/workers_test.go b/internal/manager/api_impl/workers_test.go index d0b6cffd..b512e92d 100644 --- a/internal/manager/api_impl/workers_test.go +++ b/internal/manager/api_impl/workers_test.go @@ -43,7 +43,7 @@ func TestTaskScheduleHappy(t *testing.T) { Job: job.UUID, Commands: []api.Command{}, } - assertJSONResponse(t, echo, http.StatusOK, assignedTask) + assertResponseJSON(t, echo, http.StatusOK, assignedTask) resp := getRecordedResponse(echo) assert.Equal(t, http.StatusOK, resp.StatusCode) } @@ -85,7 +85,7 @@ func TestTaskScheduleOtherStatusRequested(t *testing.T) { assert.NoError(t, err) expectBody := api.WorkerStateChange{StatusRequested: api.WorkerStatusAsleep} - assertJSONResponse(t, echoCtx, http.StatusLocked, expectBody) + assertResponseJSON(t, echoCtx, http.StatusLocked, expectBody) } func TestWorkerSignoffTaskRequeue(t *testing.T) {