Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ package goeapi

import (
"fmt"
"net"
"os"
"os/user"
"regexp"
Expand Down Expand Up @@ -460,8 +461,15 @@ func TestClientConnectInvalidTransport_UnitTest(t *testing.T) {
}

func TestClientConnectTimeout_UnitTest(t *testing.T) {
// 1.1.1.2 is assumed to be an unreachable bogus address
node, err := Connect("http", "1.1.1.2", "admin", "admin", 80)
// We create a local socket that never gives any responses
// We assume that 127.0.0.1 exists as the loopback on the test host.
sock, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatal("Error in test setup (listen).")
}
defer sock.Close()
port := sock.Addr().(*net.TCPAddr).Port
node, err := Connect("http", "127.0.0.1", "admin", "admin", port)
if err != nil {
t.Fatal("Error in connect.")
}
Expand Down