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

Function Test_NewClient_Validations

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

Source from the content-addressed store, hash-verified

8261}
8262
8263func Test_NewClient_Validations(t *testing.T) {
8264 t.Parallel()
8265
8266 tests := []struct {
8267 name string
8268 configFunc func(*Config)
8269 wantErr error
8270 validateResult func(*testing.T, *Client[pgx.Tx])
8271 }{
8272 {
8273 name: "CompletedJobRetentionPeriod cannot be less than zero",
8274 configFunc: func(config *Config) { config.CompletedJobRetentionPeriod = -1 * time.Second },
8275 wantErr: errors.New("CompletedJobRetentionPeriod cannot be less than zero"),
8276 },
8277 {
8278 name: "FetchCooldown cannot be less than FetchCooldownMin",
8279 configFunc: func(config *Config) { config.FetchCooldown = time.Millisecond - 1 },
8280 wantErr: errors.New("FetchCooldown must be at least 1ms"),
8281 },
8282 {
8283 name: "FetchCooldown cannot be negative",
8284 configFunc: func(config *Config) { config.FetchCooldown = -1 },
8285 wantErr: errors.New("FetchCooldown must be at least 1ms"),
8286 },
8287 {
8288 name: "FetchCooldown defaults to FetchCooldownDefault",
8289 configFunc: func(config *Config) { config.FetchCooldown = 0 },
8290 wantErr: nil,
8291 validateResult: func(t *testing.T, client *Client[pgx.Tx]) { //nolint:thelper
8292 require.Equal(t, FetchCooldownDefault, client.config.FetchCooldown)
8293 },
8294 },
8295 {
8296 name: "FetchCooldown cannot be less than FetchPollInterval",
8297 configFunc: func(config *Config) {
8298 config.FetchCooldown = 20 * time.Millisecond
8299 config.FetchPollInterval = 19 * time.Millisecond
8300 },
8301 wantErr: fmt.Errorf("FetchPollInterval cannot be shorter than FetchCooldown (%s)", 20*time.Millisecond),
8302 },
8303 {
8304 name: "FetchPollInterval cannot be less than MinFetchPollInterval",
8305 configFunc: func(config *Config) { config.FetchPollInterval = time.Millisecond - 1 },
8306 wantErr: errors.New("FetchPollInterval must be at least 1ms"),
8307 },
8308 {
8309 name: "FetchPollInterval cannot be negative",
8310 configFunc: func(config *Config) { config.FetchPollInterval = -1 },
8311 wantErr: errors.New("FetchPollInterval must be at least 1ms"),
8312 },
8313 {
8314 name: "FetchPollInterval defaults to DefaultFetchPollInterval",
8315 configFunc: func(config *Config) { config.FetchPollInterval = 0 },
8316 wantErr: nil,
8317 validateResult: func(t *testing.T, client *Client[pgx.Tx]) { //nolint:thelper
8318 require.Equal(t, FetchPollIntervalDefault, client.config.FetchPollInterval)
8319 },
8320 },

Callers

nothing calls this directly

Calls 11

LoggerFunction · 0.92
DBPoolFunction · 0.92
NewFunction · 0.92
TestSchemaFunction · 0.92
NewWorkersFunction · 0.85
AddWorkerFunction · 0.85
NewClientFunction · 0.85
ErrorfMethod · 0.65
ByMiddlewareKindMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…