-
Notifications
You must be signed in to change notification settings - Fork 888
feat: add dbfake for workspace builds and resources #10426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
0913ae1
to
a6fe665
Compare
This creates `coderdtest.NewWithDatabase` and adds a series of helper functions to `dbfake` that insert structured fake data for resources into the database. It allows us to remove provisionerd from a significant amount of tests which should speed them up and reduce flakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the helper functions. It would be great if we could make another AquireProvisionerJob
function to mark jobs as complete. Just mutate the job fields with some "test only" query we have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last comment, can merge without. Maybe we should not name this CreateWorkspace
, because we use that exact wording in our API related helpers which actually goes through the Create
flow and has all the deps correct.
Maybe name it InsertWorkspace
? PutWorkspace
? Some other word?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, I think this is a huge improvement for writing tests!
I did notice CI is still quite unhappy:
- pq: insert or update on table "workspace_builds" violates foreign key constraint "workspace_builds_job_id_fkey"
Perhaps just a case of missing ID in a call to dbgen (in dbfake).
This creates
coderdtest.NewWithDatabase
and adds a series of helper functions todbfake
that insert structured fake data for resources into the database.It allows us to remove provisionerd from many tests, which should speed them up and reduce flakes.
Ideally, we merge this then I convert all tests to use this new structure. It's intentionally abstract right now because I assume more patterns will emerge as I work through cases.