- Notifications
You must be signed in to change notification settings - Fork928
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
0913ae1
toa6fe665
CompareThis creates `coderdtest.NewWithDatabase` and adds a series ofhelper functions to `dbfake` that insert structured fake datafor resources into the database.It allows us to remove provisionerd from a significant amount oftests 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 anotherAquireProvisionerJob
function to mark jobs as complete. Just mutate the job fields with some "test only" query we have.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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 thisCreateWorkspace
, because we use that exact wording in our API related helpers which actually goes through theCreate
flow and has all the deps correct.
Maybe name itInsertWorkspace
?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).
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.