Skip to content

Commit

Permalink
debugging: for TestContainerCreationWithName
Browse files Browse the repository at this point in the history
Add debugging for TestContainerCreationWithName and use require.
  • Loading branch information
stevenh committed Jul 30, 2024
1 parent 4426443 commit 6cce54f
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,52 +548,41 @@ func TestContainerCreationWithName(t *testing.T) {
WaitingFor: wait.ForListeningPort(nginxDefaultPort),
Name: creationName,
Networks: []string{"bridge"},
LogConsumerCfg: &LogConsumerConfig{
Consumers: []LogConsumer{NewTestLogConsumer(t, "nginxB:")},
},
},
Started: true,
})
CleanupContainer(t, nginxC)
require.NoError(t, err)

inspect, err := nginxC.Inspect(ctx)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

name := inspect.Name
if name != expectedName {
t.Errorf("Expected container name '%s'. Got '%s'.", expectedName, name)
}
require.Equal(t, expectedName, name)

networks, err := nginxC.Networks(ctx)
if err != nil {
t.Fatal(err)
}
if len(networks) != 1 {
t.Errorf("Expected networks 1. Got '%d'.", len(networks))
}
require.NoError(t, err)
require.Len(t, networks, 1)

network := networks[0]
switch providerType {
case ProviderDocker:
if network != Bridge {
t.Errorf("Expected network name '%s'. Got '%s'.", Bridge, network)
}
require.Equal(t, Bridge, network)
case ProviderPodman:
if network != Podman {
t.Errorf("Expected network name '%s'. Got '%s'.", Podman, network)
}
require.Equal(t, Podman, network)
}

endpoint, err := nginxC.PortEndpoint(ctx, nginxDefaultPort, "http")
require.NoError(t, err)

resp, err := http.Get(endpoint)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
t.Errorf("Expected status code %d. Got %d.", http.StatusOK, resp.StatusCode)
}
require.Equal(t, http.StatusOK, resp.StatusCode)
}

func TestContainerCreationAndWaitForListeningPortLongEnough(t *testing.T) {
Expand Down

0 comments on commit 6cce54f

Please sign in to comment.