Skip to content

Commit

Permalink
debugging: for TestTwoContainersExposingTheSamePort
Browse files Browse the repository at this point in the history
Add debugging for TestTwoContainersExposingTheSamePort to determine the
cause of request failures.

Use require instead of manual check to make the tests easier to read.
  • Loading branch information
stevenh committed Jul 30, 2024
1 parent 6052acd commit 4426443
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ func TestTwoContainersExposingTheSamePort(t *testing.T) {
ExposedPorts: []string{
nginxDefaultPort,
},
LogConsumerCfg: &LogConsumerConfig{
Consumers: []LogConsumer{NewTestLogConsumer(t, "nginxA:")},
},
},
Started: true,
})
Expand All @@ -451,6 +454,9 @@ func TestTwoContainersExposingTheSamePort(t *testing.T) {
nginxDefaultPort,
},
WaitingFor: wait.ForListeningPort(nginxDefaultPort),
LogConsumerCfg: &LogConsumerConfig{
Consumers: []LogConsumer{NewTestLogConsumer(t, "nginxB:")},
},
},
Started: true,
})
Expand All @@ -461,29 +467,19 @@ func TestTwoContainersExposingTheSamePort(t *testing.T) {
require.NoError(t, err)

resp, err := http.Get(endpointA)
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)

endpointB, err := nginxB.PortEndpoint(ctx, nginxDefaultPort, "http")
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

resp, err = http.Get(endpointB)
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 TestContainerCreation(t *testing.T) {
Expand Down

0 comments on commit 4426443

Please sign in to comment.