mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: add dbfake for workspace builds and resources (#10426)
* feat: add dbfakedata for workspace builds and resources 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. * Rename dbfakedata to dbfake * Migrate workspaceagents_test.go to use the new dbfake * Migrate agent_test.go to use the new fakes * Fix comments
This commit is contained in:
@ -151,6 +151,13 @@ func New(t testing.TB, options *Options) *codersdk.Client {
|
||||
return client
|
||||
}
|
||||
|
||||
// NewWithDatabase constructs a codersdk client connected to an in-memory API instance.
|
||||
// The database is returned to provide direct data manipulation for tests.
|
||||
func NewWithDatabase(t testing.TB, options *Options) (*codersdk.Client, database.Store) {
|
||||
client, _, api := NewWithAPI(t, options)
|
||||
return client, api.Database
|
||||
}
|
||||
|
||||
// NewWithProvisionerCloser returns a client as well as a handle to close
|
||||
// the provisioner. This is a temporary function while work is done to
|
||||
// standardize how provisioners are registered with coderd. The option
|
||||
|
Reference in New Issue
Block a user