Refactor async assertions, remove manual sleeps and timeouts.

This commit is contained in:
Jay
2026-04-15 12:05:08 -04:00
parent fdae43e715
commit b128a021de
5 changed files with 189 additions and 132 deletions

View File

@@ -1,6 +1,7 @@
package honeybee
import (
"bytes"
"fmt"
"github.com/stretchr/testify/assert"
"net/http"
@@ -279,14 +280,14 @@ func TestConnect(t *testing.T) {
testData := []byte("test")
conn.Send(testData)
time.Sleep(10 * time.Millisecond)
select {
case msg := <-outgoingData:
assert.Equal(t, testData, msg.data)
case <-time.After(100 * time.Millisecond):
t.Fatal("timeout waiting for message write")
}
assert.Eventually(t, func() bool {
select {
case msg := <-outgoingData:
return bytes.Equal(msg.data, testData)
default:
return false
}
}, testTimeout, testTick)
conn.Close()
close(outgoingData)