Cleanup: rename assertResponseEmpty()
→ assertResponseNoContent()
The function tests the HTTP response is `204 No Content`, and now the name reflects that better. No functional changes.
This commit is contained in:
parent
27a6dde708
commit
b53cd67eb4
@ -188,7 +188,7 @@ func TestSetJobStatus_happy(t *testing.T) {
|
||||
err := mf.flamenco.SetJobStatus(echoCtx, jobID)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assertResponseEmpty(t, echoCtx)
|
||||
assertResponseNoContent(t, echoCtx)
|
||||
}
|
||||
|
||||
func TestSetJobStatusFailedToRequeueing(t *testing.T) {
|
||||
@ -221,7 +221,7 @@ func TestSetJobStatusFailedToRequeueing(t *testing.T) {
|
||||
err := mf.flamenco.SetJobStatus(echoCtx, jobID)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assertResponseEmpty(t, echoCtx)
|
||||
assertResponseNoContent(t, echoCtx)
|
||||
}
|
||||
|
||||
func TestSetTaskStatusQueued(t *testing.T) {
|
||||
@ -267,7 +267,7 @@ func TestSetTaskStatusQueued(t *testing.T) {
|
||||
err := mf.flamenco.SetTaskStatus(echoCtx, taskID)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assertResponseEmpty(t, echoCtx)
|
||||
assertResponseNoContent(t, echoCtx)
|
||||
}
|
||||
|
||||
func TestFetchTaskLogTail(t *testing.T) {
|
||||
@ -300,7 +300,7 @@ func TestFetchTaskLogTail(t *testing.T) {
|
||||
echoCtx := mf.prepareMockedRequest(nil)
|
||||
err := mf.flamenco.FetchTaskLogTail(echoCtx, taskID)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echoCtx)
|
||||
assertResponseNoContent(t, echoCtx)
|
||||
|
||||
// Check that a 204 No Content is also returned when the task log file on disk exists, but is empty.
|
||||
mf.persistence.EXPECT().FetchTask(gomock.Any(), taskID).Return(&dbTask, nil)
|
||||
@ -310,5 +310,5 @@ func TestFetchTaskLogTail(t *testing.T) {
|
||||
echoCtx = mf.prepareMockedRequest(nil)
|
||||
err = mf.flamenco.FetchTaskLogTail(echoCtx, taskID)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echoCtx)
|
||||
assertResponseNoContent(t, echoCtx)
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ func assertResponseAPIError(t *testing.T, echoCtx echo.Context, expectStatusCode
|
||||
})
|
||||
}
|
||||
|
||||
// assertResponseEmpty asserts the response is an empty 204 No Content response.
|
||||
func assertResponseEmpty(t *testing.T, echoCtx echo.Context) {
|
||||
// assertResponseNoContent asserts the response has no body and the given
|
||||
func assertResponseNoContent(t *testing.T, echoCtx echo.Context) {
|
||||
resp := getRecordedResponseRecorder(echoCtx)
|
||||
assert.Equal(t, http.StatusNoContent, resp.Code, "Unexpected status: %v", resp.Result().Status)
|
||||
assert.Zero(t, resp.Body.Len(), "HTTP 204 No Content should have no content, got %v", resp.Body.String())
|
||||
|
@ -159,7 +159,7 @@ func TestRequestWorkerStatusChange(t *testing.T) {
|
||||
})
|
||||
err := mf.flamenco.RequestWorkerStatusChange(echo, workerUUID)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echo)
|
||||
assertResponseNoContent(t, echo)
|
||||
}
|
||||
|
||||
func TestRequestWorkerStatusChangeRevert(t *testing.T) {
|
||||
@ -203,5 +203,5 @@ func TestRequestWorkerStatusChangeRevert(t *testing.T) {
|
||||
})
|
||||
err := mf.flamenco.RequestWorkerStatusChange(echo, workerUUID)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echo)
|
||||
assertResponseNoContent(t, echo)
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ func TestTaskUpdateFailed(t *testing.T) {
|
||||
requestWorkerStore(echoCtx, &worker)
|
||||
err := mf.flamenco.TaskUpdate(echoCtx, taskID)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echoCtx)
|
||||
assertResponseNoContent(t, echoCtx)
|
||||
}
|
||||
|
||||
{
|
||||
@ -160,7 +160,7 @@ func TestTaskUpdateFailed(t *testing.T) {
|
||||
requestWorkerStore(echoCtx, &worker)
|
||||
err := mf.flamenco.TaskUpdate(echoCtx, taskID)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echoCtx)
|
||||
assertResponseNoContent(t, echoCtx)
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ func TestBlockingAfterFailure(t *testing.T) {
|
||||
requestWorkerStore(echoCtx, &worker)
|
||||
err := mf.flamenco.TaskUpdate(echoCtx, taskID)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echoCtx)
|
||||
assertResponseNoContent(t, echoCtx)
|
||||
}
|
||||
|
||||
{
|
||||
@ -275,7 +275,7 @@ func TestBlockingAfterFailure(t *testing.T) {
|
||||
requestWorkerStore(echoCtx, &worker)
|
||||
err := mf.flamenco.TaskUpdate(echoCtx, taskID)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echoCtx)
|
||||
assertResponseNoContent(t, echoCtx)
|
||||
}
|
||||
|
||||
{
|
||||
@ -310,6 +310,6 @@ func TestBlockingAfterFailure(t *testing.T) {
|
||||
requestWorkerStore(echoCtx, &worker)
|
||||
err := mf.flamenco.TaskUpdate(echoCtx, taskID)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echoCtx)
|
||||
assertResponseNoContent(t, echoCtx)
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ func TestTaskScheduleNoTaskAvailable(t *testing.T) {
|
||||
|
||||
err := mf.flamenco.ScheduleTask(echo)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echo)
|
||||
assertResponseNoContent(t, echo)
|
||||
}
|
||||
|
||||
func TestTaskScheduleNonActiveStatus(t *testing.T) {
|
||||
@ -260,7 +260,7 @@ func TestWorkerSignoffStatusChangeRequest(t *testing.T) {
|
||||
requestWorkerStore(echo, &worker)
|
||||
err := mf.flamenco.SignOff(echo)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echo)
|
||||
assertResponseNoContent(t, echo)
|
||||
}
|
||||
|
||||
func TestWorkerStateChanged(t *testing.T) {
|
||||
@ -295,7 +295,7 @@ func TestWorkerStateChanged(t *testing.T) {
|
||||
requestWorkerStore(echo, &worker)
|
||||
err := mf.flamenco.WorkerStateChanged(echo)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echo)
|
||||
assertResponseNoContent(t, echo)
|
||||
}
|
||||
|
||||
func TestWorkerStateChangedAfterChangeRequest(t *testing.T) {
|
||||
@ -338,7 +338,7 @@ func TestWorkerStateChangedAfterChangeRequest(t *testing.T) {
|
||||
requestWorkerStore(echo, &worker)
|
||||
err := mf.flamenco.WorkerStateChanged(echo)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echo)
|
||||
assertResponseNoContent(t, echo)
|
||||
}
|
||||
|
||||
// Do another status change, which does meet the requested state.
|
||||
@ -368,7 +368,7 @@ func TestWorkerStateChangedAfterChangeRequest(t *testing.T) {
|
||||
requestWorkerStore(echo, &worker)
|
||||
err := mf.flamenco.WorkerStateChanged(echo)
|
||||
assert.NoError(t, err)
|
||||
assertResponseEmpty(t, echo)
|
||||
assertResponseNoContent(t, echo)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user