Skip to content

Commit

Permalink
fix: add more tests for un-retryable scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
p-jahn committed Apr 22, 2024
1 parent 535503c commit cdf9cae
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2102,10 +2102,30 @@ func TestDockerProvider_BuildImage_Retries(t *testing.T) {
shouldRetry: false,
},
{
name: "no retry on permanent error",
name: "no retry when a resource is not found",
errReturned: errdefs.NotFound(errors.New("not available")),
shouldRetry: false,
},
{
name: "no retry when parameters are invalid",
errReturned: errdefs.InvalidParameter(errors.New("invalid")),
shouldRetry: false,
},
{
name: "no retry when resource access not authorized",
errReturned: errdefs.Unauthorized(errors.New("not authorized")),
shouldRetry: false,
},
{
name: "no retry when resource access is forbidden",
errReturned: errdefs.Forbidden(errors.New("forbidden")),
shouldRetry: false,
},
{
name: "no retry when not implemented by provider",
errReturned: errdefs.NotImplemented(errors.New("unkown method")),
shouldRetry: false,
},
{
name: "retry on non-permanent error",
errReturned: errors.New("whoops"),
Expand Down Expand Up @@ -2143,10 +2163,15 @@ func TestDockerProvider_waitContainerCreation_retries(t *testing.T) {
shouldRetry: false,
},
{
name: "no retry on permanent error",
name: "no retry when parameters are invalid",
errReturned: errdefs.InvalidParameter(errors.New("invalid")),
shouldRetry: false,
},
{
name: "no retry when not implemented by provider",
errReturned: errdefs.NotImplemented(errors.New("unkown method")),
shouldRetry: false,
},
{
name: "retry when not found",
errReturned: errdefs.NotFound(errors.New("not there yet")),
Expand Down Expand Up @@ -2189,10 +2214,30 @@ func TestDockerProvider_attemptToPullImage_retries(t *testing.T) {
shouldRetry: false,
},
{
name: "no retry on permanent error",
name: "no retry when a resource is not found",
errReturned: errdefs.NotFound(errors.New("not available")),
shouldRetry: false,
},
{
name: "no retry when parameters are invalid",
errReturned: errdefs.InvalidParameter(errors.New("invalid")),
shouldRetry: false,
},
{
name: "no retry when resource access not authorized",
errReturned: errdefs.Unauthorized(errors.New("not authorized")),
shouldRetry: false,
},
{
name: "no retry when resource access is forbidden",
errReturned: errdefs.Forbidden(errors.New("forbidden")),
shouldRetry: false,
},
{
name: "no retry when not implemented by provider",
errReturned: errdefs.NotImplemented(errors.New("unkown method")),
shouldRetry: false,
},
{
name: "retry on non-permanent error",
errReturned: errors.New("whoops"),
Expand Down

0 comments on commit cdf9cae

Please sign in to comment.