Skip to content

Commit

Permalink
fix: timeout in integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Aug 7, 2020
1 parent 4fe810d commit a7d9596
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
2 changes: 1 addition & 1 deletion dsl/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func getAddress(rawURL string) string {
// Use this to wait for a port to be running prior
// to running tests.
var waitForPort = func(port int, network string, address string, timeoutDuration time.Duration, message string) error {
log.Println("[DEBUG] waiting for port", port, "to become available")
log.Println("[DEBUG] waiting for port", port, "to become available on", address, "after", timeoutDuration)
timeout := time.After(timeoutDuration)

for {
Expand Down
20 changes: 1 addition & 19 deletions dsl/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dsl
import (
"fmt"
"log"
"net"
"os"
"os/exec"
"reflect"
Expand Down Expand Up @@ -166,23 +165,6 @@ func TestClient_sanitiseRubyResponse(t *testing.T) {
}
}

// Use this to wait for a client to be running prior
// to running tests
func waitForPortInTest(port int, t *testing.T) {
timeout := time.After(1 * time.Second)
for {
select {
case <-timeout:
t.Fatalf("Expected server to start < 1s.")
case <-time.After(50 * time.Millisecond):
_, err := net.Dial("tcp", fmt.Sprintf(":%d", port))
if err == nil {
return
}
}
}
}

// This guy mocks out the underlying Service provider in the client,
// but executes actual client code. This means we don't spin up the real
// mock service but execute our code in isolation.
Expand Down Expand Up @@ -225,7 +207,7 @@ func createMockClient(success bool) (*PactClient, *ServiceMock) {
}()

d := newClient(svc, svc, svc, svc)
d.TimeoutDuration = 50 * time.Millisecond
d.TimeoutDuration = 100 * time.Millisecond
return d, svc
}

Expand Down

0 comments on commit a7d9596

Please sign in to comment.