MCPcopy
hub / github.com/moby/moby / TestCreateWithInvalidHealthcheckParams

Function TestCreateWithInvalidHealthcheckParams

integration/container/create_test.go:388–473  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

386}
387
388func TestCreateWithInvalidHealthcheckParams(t *testing.T) {
389 ctx := setupTest(t)
390 apiClient := testEnv.APIClient()
391
392 testCases := []struct {
393 doc string
394 interval time.Duration
395 timeout time.Duration
396 retries int
397 startPeriod time.Duration
398 startInterval time.Duration
399 expectedErr string
400 }{
401 {
402 doc: "test invalid Interval in Healthcheck: less than 0s",
403 interval: -10 * time.Millisecond,
404 timeout: time.Second,
405 retries: 1000,
406 expectedErr: fmt.Sprintf("Interval in Healthcheck cannot be less than %s", container.MinimumDuration),
407 },
408 {
409 doc: "test invalid Interval in Healthcheck: larger than 0s but less than 1ms",
410 interval: 500 * time.Microsecond,
411 timeout: time.Second,
412 retries: 1000,
413 expectedErr: fmt.Sprintf("Interval in Healthcheck cannot be less than %s", container.MinimumDuration),
414 },
415 {
416 doc: "test invalid Timeout in Healthcheck: less than 1ms",
417 interval: time.Second,
418 timeout: -100 * time.Millisecond,
419 retries: 1000,
420 expectedErr: fmt.Sprintf("Timeout in Healthcheck cannot be less than %s", container.MinimumDuration),
421 },
422 {
423 doc: "test invalid Retries in Healthcheck: less than 0",
424 interval: time.Second,
425 timeout: time.Second,
426 retries: -10,
427 expectedErr: "Retries in Healthcheck cannot be negative",
428 },
429 {
430 doc: "test invalid StartPeriod in Healthcheck: not 0 and less than 1ms",
431 interval: time.Second,
432 timeout: time.Second,
433 retries: 1000,
434 startPeriod: 100 * time.Microsecond,
435 expectedErr: fmt.Sprintf("StartPeriod in Healthcheck cannot be less than %s", container.MinimumDuration),
436 },
437 {
438 doc: "test invalid StartInterval in Healthcheck: not 0 and less than 1ms",
439 interval: time.Second,
440 timeout: time.Second,
441 retries: 1000,
442 startPeriod: time.Second,
443 startInterval: 100 * time.Microsecond,
444 expectedErr: fmt.Sprintf("StartInterval in Healthcheck cannot be less than %s", container.MinimumDuration),
445 },

Callers

nothing calls this directly

Calls 7

StartSpanFunction · 0.92
APIClientMethod · 0.80
CheckMethod · 0.80
EqualMethod · 0.80
setupTestFunction · 0.70
RunMethod · 0.65
ContainerCreateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…