diff --git a/integration-cli/docker_api_test.go b/integration-cli/docker_api_test.go index 4448f141f7..5b307415f6 100644 --- a/integration-cli/docker_api_test.go +++ b/integration-cli/docker_api_test.go @@ -50,14 +50,3 @@ func (s *DockerAPISuite) TestAPIErrorJSON(c *testing.T) { assert.NilError(c, err) assert.Check(c, is.Contains(getErrorMessage(c, b), "config cannot be empty")) } - -func (s *DockerAPISuite) TestAPIErrorNotFoundJSON(c *testing.T) { - // 404 is a different code path to normal errors, so test separately - httpResp, body, err := request.Get(testutil.GetContext(c), "/notfound", request.JSON) - assert.NilError(c, err) - assert.Equal(c, httpResp.StatusCode, http.StatusNotFound) - assert.Assert(c, is.Contains(httpResp.Header.Get("Content-Type"), "application/json")) - b, err := request.ReadBody(body) - assert.NilError(c, err) - assert.Equal(c, getErrorMessage(c, b), "page not found") -} diff --git a/integration/system/api_test.go b/integration/system/api_test.go new file mode 100644 index 0000000000..888feea248 --- /dev/null +++ b/integration/system/api_test.go @@ -0,0 +1,23 @@ +package system + +import ( + "net/http" + "testing" + + "github.com/moby/moby/api/types/common" + "github.com/moby/moby/v2/internal/testutil/request" + "gotest.tools/v3/assert" +) + +func TestAPIErrorNotFoundJSON(t *testing.T) { + ctx := setupTest(t) + + // 404 is a different code path to normal errors, so test separately + httpResp, _, err := request.Get(ctx, "/notfound", request.JSON) + assert.NilError(t, err) + assert.Equal(t, httpResp.StatusCode, http.StatusNotFound) + + var respErr common.ErrorResponse + assert.NilError(t, request.ReadJSONResponse(httpResp, &respErr)) + assert.Error(t, respErr, "page not found") +}