Skip to content

Add better mocking for stores

Created by: camdencheek

This tracks the progress towards implementation of #26129.

Game plan:

  • Convert store structs to interfaces and generate mocks for each store
  • Mint database.DB type that has methods to return specific store types
  • Move store doc comments from implementing structs to interface
  • Replace global mocks with injected mocks
  • Replace uses of dbutil.DB with database.DB (in progress)
  • Replace uses of database constructor functions with database.DB methods (in progress)
  • Figure out how to handle enterprise-only stores in a mockable way
  • Change database.NewDB() to take a *sql.DB rather than a dbutil.DB
  • Update transaction code to avoid casing on the concrete type of a dbutil.DB
  • Remove uses of dbconn.Global since it can't be mocked: done

See progress in a code insights dashboard here