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

Function Test_Client_Start_Error

client_test.go:7876–7959  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7874}
7875
7876func Test_Client_Start_Error(t *testing.T) {
7877 t.Parallel()
7878
7879 ctx := context.Background()
7880
7881 t.Run("NoQueueConfiguration", func(t *testing.T) {
7882 t.Parallel()
7883
7884 var (
7885 dbPool = riversharedtest.DBPool(ctx, t)
7886 driver = riverpgxv5.New(dbPool)
7887 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
7888 config = newTestConfig(t, schema)
7889 )
7890 config.Queues = nil
7891 config.Workers = nil
7892
7893 client := newTestClient(t, dbPool, config)
7894 err := client.Start(ctx)
7895 require.EqualError(t, err, "client Queues and Workers must be configured for a client to start working")
7896 })
7897
7898 t.Run("NoRegisteredWorkers", func(t *testing.T) {
7899 t.Parallel()
7900
7901 var (
7902 dbPool = riversharedtest.DBPool(ctx, t)
7903 driver = riverpgxv5.New(dbPool)
7904 schema = riverdbtest.TestSchema(ctx, t, driver, nil)
7905 config = newTestConfig(t, schema)
7906 )
7907 config.Workers = NewWorkers() // initialized, but empty
7908
7909 client := newTestClient(t, dbPool, config)
7910 err := client.Start(ctx)
7911 require.EqualError(t, err, "at least one Worker must be added to the Workers bundle")
7912 })
7913
7914 t.Run("DatabaseError", func(t *testing.T) {
7915 t.Parallel()
7916
7917 dbConfig := riversharedtest.DBPool(ctx, t).Config().Copy()
7918 dbConfig.ConnConfig.Database = "does-not-exist-and-dont-create-it"
7919
7920 dbPool, err := pgxpool.NewWithConfig(ctx, dbConfig)
7921 require.NoError(t, err)
7922
7923 config := newTestConfig(t, "")
7924
7925 client := newTestClient(t, dbPool, config)
7926
7927 err = client.Start(ctx)
7928 require.Error(t, err)
7929
7930 var pgErr *pgconn.PgError
7931 require.ErrorAs(t, err, &pgErr)
7932 require.Equal(t, pgerrcode.InvalidCatalogName, pgErr.Code)
7933 })

Callers

nothing calls this directly

Calls 9

DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
newTestClientFunction · 0.85
NewWorkersFunction · 0.85
newTestConfigFunction · 0.70
RunMethod · 0.65
StartMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…