(t *testing.T)
| 3624 | } |
| 3625 | |
| 3626 | func Test_Client_InsertManyFast(t *testing.T) { |
| 3627 | t.Parallel() |
| 3628 | |
| 3629 | ctx := context.Background() |
| 3630 | |
| 3631 | type testBundle struct { |
| 3632 | dbPool *pgxpool.Pool |
| 3633 | schema string |
| 3634 | } |
| 3635 | |
| 3636 | setup := func(t *testing.T) (*Client[pgx.Tx], *testBundle) { |
| 3637 | t.Helper() |
| 3638 | |
| 3639 | var ( |
| 3640 | dbPool = riversharedtest.DBPool(ctx, t) |
| 3641 | driver = riverpgxv5.New(dbPool) |
| 3642 | schema = riverdbtest.TestSchema(ctx, t, driver, nil) |
| 3643 | config = newTestConfig(t, schema) |
| 3644 | client = newTestClient(t, dbPool, config) |
| 3645 | ) |
| 3646 | |
| 3647 | return client, &testBundle{ |
| 3648 | dbPool: dbPool, |
| 3649 | schema: schema, |
| 3650 | } |
| 3651 | } |
| 3652 | |
| 3653 | t.Run("SucceedsWithMultipleJobs", func(t *testing.T) { |
| 3654 | t.Parallel() |
| 3655 | |
| 3656 | client, _ := setup(t) |
| 3657 | |
| 3658 | count, err := client.InsertManyFast(ctx, []InsertManyParams{ |
| 3659 | {Args: noOpArgs{}, InsertOpts: &InsertOpts{Queue: "foo", Priority: 2}}, |
| 3660 | {Args: noOpArgs{}}, |
| 3661 | }) |
| 3662 | require.NoError(t, err) |
| 3663 | require.Equal(t, 2, count) |
| 3664 | |
| 3665 | jobs, err := client.driver.GetExecutor().JobGetByKindMany(ctx, &riverdriver.JobGetByKindManyParams{ |
| 3666 | Kind: []string{(noOpArgs{}).Kind()}, |
| 3667 | Schema: client.config.Schema, |
| 3668 | }) |
| 3669 | |
| 3670 | require.NoError(t, err) |
| 3671 | require.Len(t, jobs, 2, "Expected to find exactly two jobs of kind: "+(noOpArgs{}).Kind()) |
| 3672 | }) |
| 3673 | |
| 3674 | t.Run("TriggersImmediateWork", func(t *testing.T) { |
| 3675 | t.Parallel() |
| 3676 | |
| 3677 | ctx := context.Background() |
| 3678 | |
| 3679 | _, bundle := setup(t) |
| 3680 | |
| 3681 | ctx, cancel := context.WithTimeout(ctx, 10*time.Second) |
| 3682 | t.Cleanup(cancel) |
| 3683 |
nothing calls this directly
no test coverage detected
searching dependent graphs…