@@ -186,6 +186,18 @@ func User(t *testing.T, db database.Store, orig database.User) database.User {
186
186
return user
187
187
}
188
188
189
+ func GitSSHKey (t * testing.T ,db database.Store ,orig database.GitSSHKey ) database.GitSSHKey {
190
+ key ,err := db .InsertGitSSHKey (context .Background (), database.InsertGitSSHKeyParams {
191
+ UserID :takeFirst (orig .UserID ,uuid .New ()),
192
+ CreatedAt :takeFirst (orig .CreatedAt ,time .Now ()),
193
+ UpdatedAt :takeFirst (orig .UpdatedAt ,time .Now ()),
194
+ PrivateKey :takeFirst (orig .PrivateKey ,"" ),
195
+ PublicKey :takeFirst (orig .PublicKey ,"" ),
196
+ })
197
+ require .NoError (t ,err ,"insert ssh key" )
198
+ return key
199
+ }
200
+
189
201
func Organization (t * testing.T ,db database.Store ,orig database.Organization ) database.Organization {
190
202
org ,err := db .InsertOrganization (context .Background (), database.InsertOrganizationParams {
191
203
ID :takeFirst (orig .ID ,uuid .New ()),
@@ -254,6 +266,34 @@ func ProvisionerJob(t *testing.T, db database.Store, orig database.ProvisionerJo
254
266
return job
255
267
}
256
268
269
+ func WorkspaceApp (t * testing.T ,db database.Store ,orig database.WorkspaceApp ) database.WorkspaceApp {
270
+ resource ,err := db .InsertWorkspaceApp (context .Background (), database.InsertWorkspaceAppParams {
271
+ ID :takeFirst (orig .ID ,uuid .New ()),
272
+ CreatedAt :takeFirst (orig .CreatedAt ,time .Now ()),
273
+ AgentID :takeFirst (orig .AgentID ,uuid .New ()),
274
+ Slug :takeFirst (orig .Slug ,namesgenerator .GetRandomName (1 )),
275
+ DisplayName :takeFirst (orig .DisplayName ,namesgenerator .GetRandomName (1 )),
276
+ Icon :takeFirst (orig .Icon ,namesgenerator .GetRandomName (1 )),
277
+ Command : sql.NullString {
278
+ String :takeFirst (orig .Command .String ,"ls" ),
279
+ Valid :orig .Command .Valid ,
280
+ },
281
+ Url : sql.NullString {
282
+ String :takeFirst (orig .Url .String ),
283
+ Valid :orig .Url .Valid ,
284
+ },
285
+ External :orig .External ,
286
+ Subdomain :orig .Subdomain ,
287
+ SharingLevel :takeFirst (orig .SharingLevel ,database .AppSharingLevelOwner ),
288
+ HealthcheckUrl :takeFirst (orig .HealthcheckUrl ,"https://localhost:8000" ),
289
+ HealthcheckInterval :takeFirst (orig .HealthcheckInterval ,60 ),
290
+ HealthcheckThreshold :takeFirst (orig .HealthcheckThreshold ,60 ),
291
+ Health :takeFirst (orig .Health ,database .WorkspaceAppHealthHealthy ),
292
+ })
293
+ require .NoError (t ,err ,"insert app" )
294
+ return resource
295
+ }
296
+
257
297
func WorkspaceResource (t * testing.T ,db database.Store ,orig database.WorkspaceResource ) database.WorkspaceResource {
258
298
resource ,err := db .InsertWorkspaceResource (context .Background (), database.InsertWorkspaceResourceParams {
259
299
ID :takeFirst (orig .ID ,uuid .New ()),
@@ -312,6 +352,21 @@ func UserLink(t *testing.T, db database.Store, orig database.UserLink) database.
312
352
return link
313
353
}
314
354
355
+ func GitAuthLink (t * testing.T ,db database.Store ,orig database.GitAuthLink ) database.GitAuthLink {
356
+ link ,err := db .InsertGitAuthLink (context .Background (), database.InsertGitAuthLinkParams {
357
+ ProviderID :takeFirst (orig .ProviderID ,uuid .New ().String ()),
358
+ UserID :takeFirst (orig .UserID ,uuid .New ()),
359
+ OAuthAccessToken :takeFirst (orig .OAuthAccessToken ,uuid .NewString ()),
360
+ OAuthRefreshToken :takeFirst (orig .OAuthAccessToken ,uuid .NewString ()),
361
+ OAuthExpiry :takeFirst (orig .OAuthExpiry ,time .Now ().Add (time .Hour * 24 )),
362
+ CreatedAt :takeFirst (orig .CreatedAt ,time .Now ()),
363
+ UpdatedAt :takeFirst (orig .UpdatedAt ,time .Now ()),
364
+ })
365
+
366
+ require .NoError (t ,err ,"insert git auth link" )
367
+ return link
368
+ }
369
+
315
370
func TemplateVersion (t * testing.T ,db database.Store ,orig database.TemplateVersion ) database.TemplateVersion {
316
371
version ,err := db .InsertTemplateVersion (context .Background (), database.InsertTemplateVersionParams {
317
372
ID :takeFirst (orig .ID ,uuid .New ()),