Fix unit tests on Darwin (#4458)

This commit is contained in:
maxunt
2018-07-27 18:29:54 -07:00
committed by Daniel Nelson
parent 83c4b81abe
commit 96cb0aaea0
9 changed files with 50 additions and 79 deletions

View File

@@ -403,13 +403,16 @@ func testStrictRFC5425(t *testing.T, protocol string, address string, wantTLS bo
acc.Errors = make([]error, 0)
// Write
conn.Write(tc.data)
_, err = conn.Write(tc.data)
conn.Close()
require.NoError(t, err)
// Wait that the the number of data points is accumulated
// Since the receiver is running concurrently
if tc.wantStrict != nil {
acc.Wait(len(tc.wantStrict))
}
// Wait the parsing error
acc.WaitError(tc.werr)
@@ -452,7 +455,6 @@ func testBestEffortRFC5425(t *testing.T, protocol string, address string, wantTL
conn, err = tls.Dial(protocol, address, config)
} else {
conn, err = net.Dial(protocol, address)
defer conn.Close()
}
require.NotNil(t, conn)
require.NoError(t, err)
@@ -462,7 +464,9 @@ func testBestEffortRFC5425(t *testing.T, protocol string, address string, wantTL
acc.Errors = make([]error, 0)
// Write
conn.Write(tc.data)
_, err = conn.Write(tc.data)
require.NoError(t, err)
conn.Close()
// Wait that the the number of data points is accumulated
// Since the receiver is running concurrently

View File

@@ -234,12 +234,18 @@ func testRFC5426(t *testing.T, protocol string, address string, bestEffort bool)
// Connect
conn, err := net.Dial(protocol, address)
require.NotNil(t, conn)
defer conn.Close()
require.Nil(t, err)
// Write
_, e := conn.Write(tc.data)
require.Nil(t, e)
_, err = conn.Write(tc.data)
conn.Close()
if err != nil {
if err, ok := err.(*net.OpError); ok {
if err.Err.Error() == "write: message too long" {
return
}
}
}
// Waiting ...
if tc.wantStrict == nil && tc.werr || bestEffort && tc.werr {