Skip to content

🐛 Bug Report: Generated app - user controller test - use HttpStatus code #2387

@tupe12334

Description

@tupe12334

What happened?

When we generate a controller test for the user we use in the 404 test the number instead of the HttpStatus.NOT_FOUND enum

What you expected to happen

We use const or enum variables

The old:

  test("GET /customers/:id non existing", async () => {
    await request(app.getHttpServer())
      .get(`${"/customers"}/${nonExistingId}`)
      .expect(404)
      .expect({
        statusCode: 404,
        message: `No resource was found for {"${"id"}":"${nonExistingId}"}`,
        error: "Not Found",
      });
  });

The Wanted:

  test("GET /customers/:id non existing", async () => {
    await request(app.getHttpServer())
      .get(`${"/customers"}/${nonExistingId}`)
      .expect(HttpStatus.NOT_FOUND)
      .expect({
        statusCode: HttpStatus.NOT_FOUND,
        message: `No resource was found for {"${"id"}":"${nonExistingId}"}`,
        error: "Not Found",
      });
  });

How to reproduce

generate an app -> go to any controller test -> see the GET id not exist test

Amplication version

0.12.0

Environment

No response

Are you willing to submit PR?

Yes I am willing to submit a PR!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions