Skip to content

Commit

Permalink
Fixed nil IP address bug. Changed the way how the test TCP address is…
Browse files Browse the repository at this point in the history
… built.
  • Loading branch information
cihub committed Oct 19, 2012
1 parent e0d9328 commit e4e04f2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions writers_connwriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ type testObj struct {
Time time.Time
}

const (
testIPAddress = "localhost"
)

var (
connWriterLog1 = "Testasasaafasf"
connWriterLog2 = "fgrehgsnkmrgergerg[234%:dfsads:2]"
Expand All @@ -46,6 +50,10 @@ var (
obj = &testObj{11, "sdfasd", 12.5, time.Now()}
)

func getTestTCPAddress(port string) string {
return testIPAddress + ":" + port
}

func TestConnWriter_ReconnectOnMessage(t *testing.T) {
server, err := startTcpServer(t)
if err != nil {
Expand All @@ -55,7 +63,7 @@ func TestConnWriter_ReconnectOnMessage(t *testing.T) {

server.Expect(connWriterLog)

writer := newConnWriter("tcp4", ":"+server.port, true)
writer := newConnWriter("tcp4", getTestTCPAddress(server.port), true)
defer writer.Close()

_, err = writer.Write([]byte(connWriterLog))
Expand All @@ -77,7 +85,7 @@ func TestConnWriter_OneConnect(t *testing.T) {

server.Expect(connWriterLog)

writer := newConnWriter("tcp4", ":"+server.port, false)
writer := newConnWriter("tcp4", getTestTCPAddress(server.port), false)

_, err = writer.Write([]byte(connWriterLog1))
if err != nil {
Expand Down Expand Up @@ -112,7 +120,7 @@ func TestConnWriter_ReconnectOnMessage_WriteError(t *testing.T) {

server.Expect(connWriterLog)

writer := newConnWriter("tcp4", ":"+server.port, true)
writer := newConnWriter("tcp4", getTestTCPAddress(server.port), true)
defer writer.Close()

_, err = writer.Write([]byte(connWriterLog))
Expand Down

0 comments on commit e4e04f2

Please sign in to comment.