Course overview/Make failure loud2 of 3

Unit-test the logic

Unit-test the logic

Test SQL transformations with controlled inputs and exact expected rows before trusting the output.

Checks and unit tests answer different questions

A quality check asks whether a finished table is acceptable. A unit test supplies a small, controlled set of input rows and asks whether the query transforms them correctly. inputs, expected.rows, match: exact, and expected counts turn that expectation into a test the agent can run.

Useful cases include a customer with no orders, a NULL order status, tied ranking values, a week with no data, and a negative refund. The shipped tests demonstrate the pattern; add the cases that best protect the model contract without weakening an expected result.

Your task

Add four unit tests to the appropriate asset headers, for at least six total. Cover a no-order customer, a NULL-status order, a tie with deterministic ordering, a week with no data, and a negative refund. One test may cover two related cases if its inputs and expected output make both assertions explicit. Run:

bruin unit-test pipeline

Record the results in docs/unit-tests.md.

Check your understanding

  • What does match: exact require?
  • Which join preserves a customer with no orders?
  • Should a failing test be weakened to make the run pass?

Do it with your agent

Say next lesson, add the tests yourself, run the unit-test command, then say review my work.

Rubric

  • Adds at least 4 new tests, so the project has at least 6 total.
  • Includes exact mocked inputs and expected outputs for no-order and no-data-week cases.
  • Includes a negative-refund case and explains whether the model preserves or excludes it.
  • Records a passing bruin unit-test pipeline run.
  • All shipped tests pass without changing an expected result to hide a failure.

Sign up to our newsletter

Practical updates on open-source data pipelines, AI analysts, governance, and what we are shipping at Bruin.

The signup form is hosted by Brevo. Allow marketing cookies to load it.