MCPcopy Index your code
hub / github.com/riverqueue/river / requireNotInsertedErr

Function requireNotInsertedErr

rivertest/rivertest.go:262–305  ·  view source on GitHub ↗
(ctx context.Context, t testingT, exec riverdriver.Executor, expectedJob TArgs, opts *RequireInsertedOpts)

Source from the content-addressed store, hash-verified

260}
261
262func requireNotInsertedErr[TDriver riverdriver.Driver[TTx], TTx any, TArgs river.JobArgs](ctx context.Context, t testingT, exec riverdriver.Executor, expectedJob TArgs, opts *RequireInsertedOpts) error {
263 t.Helper()
264
265 var schema string
266 if opts != nil {
267 schema = opts.Schema
268 }
269
270 // Returned ordered by ID.
271 jobRows, err := exec.JobGetByKindMany(ctx, &riverdriver.JobGetByKindManyParams{
272 Kind: []string{expectedJob.Kind()},
273 Schema: schema,
274 })
275 if err != nil {
276 return fmt.Errorf("error querying jobs: %w", err)
277 }
278
279 if len(jobRows) < 1 {
280 return nil
281 }
282
283 if len(jobRows) > 0 && opts == nil {
284 failuref(t, "%d jobs found with kind, but expected to find none: %s", len(jobRows), expectedJob.Kind())
285 return nil
286 }
287
288 // If any of these job rows failed assertions against opts, then the test
289 // fails, but if they all succeed, then we consider no matching jobs to have
290 // been inserted, and the test succeeds.
291 for _, jobRow := range jobRows {
292 var actualArgs TArgs
293 if err := json.Unmarshal(jobRow.EncodedArgs, &actualArgs); err != nil {
294 return fmt.Errorf("error unmarshaling job args: %w", err)
295 }
296
297 if opts != nil {
298 if !compareJobToInsertOpts(t, jobRow, opts, -1, true) {
299 return nil
300 }
301 }
302 }
303
304 return nil
305}
306
307// ExpectedJob is a single job to expect encapsulating job args and possible
308// insertion options.

Callers

nothing calls this directly

Calls 6

failurefFunction · 0.85
compareJobToInsertOptsFunction · 0.85
HelperMethod · 0.65
JobGetByKindManyMethod · 0.65
KindMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…