@@ -2175,6 +2175,41 @@ func (s *MethodTestSuite) TestExtraMethods() {
2175
2175
LastSeenAt : sql.NullTime {Time : dbtime .Now (), Valid : true },
2176
2176
}).Asserts (rbac .ResourceProvisionerDaemon , policy .ActionUpdate )
2177
2177
}))
2178
+ s .Run ("GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisioner" , s .Subtest (func (db database.Store , check * expects ) {
2179
+ org := dbgen .Organization (s .T (), db , database.Organization {})
2180
+ tags := database .StringMap (map [string ]string {
2181
+ provisionersdk .TagScope : provisionersdk .ScopeOrganization ,
2182
+ })
2183
+ t := dbgen .Template (s .T (), db , database.Template {})
2184
+ tv := dbgen .TemplateVersion (s .T (), db , database.TemplateVersion {TemplateID : uuid.NullUUID {UUID : t .ID , Valid : true }})
2185
+ w := dbgen .Workspace (s .T (), db , database.WorkspaceTable {OrganizationID : org .ID , TemplateID : t .ID })
2186
+ wb := dbgen .WorkspaceBuild (s .T (), db , database.WorkspaceBuild {WorkspaceID : w .ID , TemplateVersionID : tv .ID })
2187
+ j1 , err := db .InsertProvisionerJob (context .Background (), database.InsertProvisionerJobParams {
2188
+ OrganizationID : org .ID ,
2189
+ Type : database .ProvisionerJobTypeTemplateVersionImport ,
2190
+ Input : []byte (`{"template_version_id":"` + tv .ID .String () + `"}` ),
2191
+ Tags : tags ,
2192
+ Provisioner : database .ProvisionerTypeEcho ,
2193
+ StorageMethod : database .ProvisionerStorageMethodFile ,
2194
+ })
2195
+ s .NoError (err , "insert provisioner job" )
2196
+ j2 , err := db .InsertProvisionerJob (context .Background (), database.InsertProvisionerJobParams {
2197
+ OrganizationID : org .ID ,
2198
+ Type : database .ProvisionerJobTypeWorkspaceBuild ,
2199
+ Input : []byte (`{"workspace_build_id":"` + wb .ID .String () + `"}` ),
2200
+ Tags : tags ,
2201
+ Provisioner : database .ProvisionerTypeEcho ,
2202
+ StorageMethod : database .ProvisionerStorageMethodFile ,
2203
+ })
2204
+ s .NoError (err , "insert provisioner job" )
2205
+ ds , err := db .GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisioner (context .Background (), database.GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisionerParams {
2206
+ OrganizationID : uuid.NullUUID {Valid : true , UUID : org .ID },
2207
+ })
2208
+ s .NoError (err , "get provisioner jobs by org" )
2209
+ check .Args (database.GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisionerParams {
2210
+ OrganizationID : uuid.NullUUID {Valid : true , UUID : org .ID },
2211
+ }).Asserts (j1 , policy .ActionRead , j2 , policy .ActionRead ).Returns (ds )
2212
+ }))
2178
2213
}
2179
2214
2180
2215
// All functions in this method test suite are not implemented in dbmem, but
0 commit comments