DeepLcom / sql-mock

A Python library to test your SQL models using mocked input data
MIT License
33 stars 5 forks source link

Error handling improvements #25

Closed Somtom closed 9 months ago

Somtom commented 9 months ago

Problem

Often when creating first SQLMock tests, the tests tend to fail because of wrong setup reasons. We forget to mock a specific table reference or we gave some wrong input values. Currently, it is hard to debug for new users and we should improve this

What changed

This commit adds improved error handling that also make debugging easier:

  1. We validate provided input mocks for completeness (i.e. are all table references mocked)
  2. We validate provided input mocks to be correct (i.e. actually present in the query and not duplicated)
  3. We print the last query if a test failed. This can also help debugging what went wrong