SQL (SQLite engine)

Test a create through the app to the DB

Medium70 pts~25 min
  • End-to-end create
  • Header/line consistency
Practice app · Acme Commerce DB

A real SQL database (SQLite engine) seeded with an e-commerce and HR dataset, with schema browser and query runner.

Test URL
/lab/database-testing-test-a-create-through-the-app-to-the-db

Your starter code already declares TEST_URL — never hardcode a host.

Objective

Replay the writes the checkout service performs for a new order and verify the order header agrees with its lines.

Your task

  1. 1Insert an order for customer 2: order_date '2025-12-30', status 'pending', total 82.97 (it gets id 61).
  2. 2Insert its lines into order_items: product 11 × 2 at 34.99 and product 12 × 1 at 12.99.
  3. 3Verify: SELECT o.id, ROUND(o.total, 2) = ROUND(SUM(i.quantity * i.unit_price), 2) AS total_matches_items, COUNT(i.id) AS lines FROM orders o JOIN order_items i ON i.order_id = o.id WHERE o.id = 61 GROUP BY o.id, o.total.

Acceptance criteria

  • Order 61 and its two lines are stored with the expected values
  • The last result set is (61, 1, 2): totals agree and there are 2 lines

Constraints

  • Every run starts from a freshly seeded database, so your script must include its own setup statements.
  • Only the last result set of your script is compared, so finish with the verification query.

SQL (SQLite engine) · Database Testing · CRUD & data integrity