(t *testing.T)
| 8261 | } |
| 8262 | |
| 8263 | func 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 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…