Tente resolver a tarefa antes de consultar os critérios. Compare o resultado e explique o que mudou no seu raciocínio.
Task, 15 minutes: an order endpoint accepts an integer quantity greater than zero. It saves the order and a durable receipt event in the same database transaction. A retry with the same idempotency key must not create another order or receipt event. Write a test plan for invalid input, the minimum valid quantity, concurrent duplicates, transaction failure, and successful order history before writing assertions.
Check your work:
- A focused validation test covers quantity 0, a valid quantity, and the boundary value 1 with explicit expected outcomes.
- An integration test uses the real local database and two concurrent requests with the same key. Assert one saved order and one durable receipt event. A mocked repository cannot prove the unique constraint works.
- A failure case proves an unsuccessful transaction does not leave an order or receipt event committed.
- One user-flow check confirms a successful order appears once in order history. Assert visible behavior instead of a private helper call sequence.
Name the missing failure that each test detects. Keep preparation, action, and verification visually separate. If an async operation rejects, return or await the assertion so the test cannot finish early.
No app, a tarefa fica visível e você pode revelar os critérios depois da tentativa. Use as notas para registrar sua solução.
Praticar este exercício no app