MCPcopy Index your code
hub / github.com/coder/coder / expectProvisionerJob

Function expectProvisionerJob

coderd/wsbuilder/wsbuilder_test.go:1482–1497  ·  view source on GitHub ↗

Since there is expected to be only one each of job, build, and build-parameters inserted, instead of building matchers, we match any call and then assert its parameters. This will feel more familiar to the way we write other tests. expectProvisionerJob captures a call to InsertProvisionerJob and ru

(
	assertions func(job database.InsertProvisionerJobParams),
)

Source from the content-addressed store, hash-verified

1480// expectProvisionerJob captures a call to InsertProvisionerJob and runs the provided assertions
1481// against it.
1482func expectProvisionerJob(
1483 assertions func(job database.InsertProvisionerJobParams),
1484) func(mTx *dbmock.MockStore) {
1485 return func(mTx *dbmock.MockStore) {
1486 mTx.EXPECT().InsertProvisionerJob(gomock.Any(), gomock.Any()).
1487 Times(1).
1488 DoAndReturn(
1489 func(ctx context.Context, params database.InsertProvisionerJobParams) (database.ProvisionerJob, error) {
1490 assertions(params)
1491 // there is no point copying anything other than the ID, since this object is just
1492 // returned to our test code, and we've already asserted what we care about.
1493 return database.ProvisionerJob{ID: params.ID}, nil
1494 },
1495 )
1496 }
1497}
1498
1499// expectUpdateProvisionerJobWithCompleteWithStartedAtByID asserts a call to
1500// expectUpdateProvisionerJobWithCompleteWithStartedAtByID and runs the provided

Calls 2

InsertProvisionerJobMethod · 0.65
EXPECTMethod · 0.45

Tested by

no test coverage detected