Skip to content

Commit

Permalink
Increase context timeout and manage cancellation for TestContainerNon…
Browse files Browse the repository at this point in the history
…ExistentImage

Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
  • Loading branch information
Erdem Toraman authored and Gianluca Arbezzano committed Mar 3, 2020
1 parent 7af9b0f commit 385ce1c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"errors"
"fmt"
"github.com/docker/docker/errdefs"
"net/http"
"path/filepath"
"testing"
"time"

"github.com/docker/docker/errdefs"

"github.com/docker/docker/api/types/volume"

"database/sql"
Expand Down Expand Up @@ -38,7 +39,7 @@ func TestContainerAttachedToNewNetwork(t *testing.T) {
networkName,
},
NetworkAliases: map[string][]string{
networkName: []string{
networkName: {
"alias1", "alias2", "alias3",
},
},
Expand Down Expand Up @@ -1187,7 +1188,8 @@ func TestContainerNonExistentImage(t *testing.T) {
t.Run("if the image not found don't propagate the error", func(t *testing.T) {
_, err := GenericContainer(context.Background(), GenericContainerRequest{
ContainerRequest: ContainerRequest{
Image: "postgres:nonexistent-version",
Image: "postgres:nonexistent-version",
SkipReaper: true,
},
Started: true,
})
Expand All @@ -1199,11 +1201,13 @@ func TestContainerNonExistentImage(t *testing.T) {
})

t.Run("the context cancellation is propagated to container creation", func(t *testing.T) {
ctx, _ := context.WithTimeout(context.Background(), time.Millisecond*100)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
_, err := GenericContainer(ctx, GenericContainerRequest{
ContainerRequest: ContainerRequest{
Image: "postgres:latest",
WaitingFor: wait.ForLog("log"),
SkipReaper: true,
},
Started: true,
})
Expand Down

0 comments on commit 385ce1c

Please sign in to comment.