Use a SQL mock driver to test database interactions #74

Closed
opened 2026-02-19 23:01:46 -05:00 by deekerman · 3 comments
Owner

Originally created by @lastzero on GitHub (Dec 20, 2018).

Originally assigned to: @lastzero on GitHub.

As a developer, I want to test database interactions without needing a real database connection to improve reliability and performance of my tests.

We'll still need a real test database like TiDB or MySQL for (most) integration and acceptance tests, see #60.

Acceptance Criteria:

  • A proof-of-concept for using a SQL mock driver in unit tests MUST be delivered (real test case)
  • Existing tests SHOULD be refactored to use this mock driver, whenever it makes sense
  • https://github.com/DATA-DOG/go-sqlmock SHOULD be used (unless you find a better solution)
  • If there are any unsolvable issues related to using a mock driver, those MUST be documented and you MAY close this ticket
  • Proper use and known limitations of the mock driver MUST be documented in our Developer Guide
Originally created by @lastzero on GitHub (Dec 20, 2018). Originally assigned to: @lastzero on GitHub. **As a developer, I want to test database interactions without needing a real database connection to improve reliability and performance of my tests.** We'll still need a real test database like TiDB or MySQL for (most) integration and acceptance tests, see #60. Acceptance Criteria: - [ ] A proof-of-concept for using a SQL mock driver in unit tests MUST be delivered (real test case) - [ ] Existing tests SHOULD be refactored to use this mock driver, whenever it makes sense - [ ] https://github.com/DATA-DOG/go-sqlmock SHOULD be used (unless you find a better solution) - [ ] If there are any unsolvable issues related to using a mock driver, those MUST be documented and you MAY close this ticket - [ ] Proper use and known limitations of the mock driver MUST be documented in our [Developer Guide](https://github.com/photoprism/photoprism/wiki/Tests)
Author
Owner

@mingh168 commented on GitHub (Aug 10, 2019):

@lastzero can i have a go at this one please, Thanks

@mingh168 commented on GitHub (Aug 10, 2019): @lastzero can i have a go at this one please, Thanks
Author
Owner

@lastzero commented on GitHub (Aug 10, 2019):

Yes, please :)

I've been on vacation, will be more active in September again to work on the remaining issues...

@lastzero commented on GitHub (Aug 10, 2019): Yes, please :) I've been on vacation, will be more active in September again to work on the remaining issues...
Author
Owner

@lastzero commented on GitHub (Jan 5, 2020):

After a lot of discussions, we decided to use a real db for testing since this causes least overhead and we have limited resources (we're aware about the tradeoffs). Database fixtures will be put in assets/resources/examples/fixtures.sql and must be maintained manually for now.

@lastzero commented on GitHub (Jan 5, 2020): After a lot of discussions, we decided to use a real db for testing since this causes least overhead and we have limited resources (we're aware about the tradeoffs). Database fixtures will be put in `assets/resources/examples/fixtures.sql` and must be maintained manually for now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/photoprism#74
No description provided.