Simplify tests and avoid unnecessary race conditions.

This commit is contained in:
Jay
2026-04-15 13:47:34 -04:00
parent b128a021de
commit d002c19889
5 changed files with 18 additions and 77 deletions

View File

@@ -128,21 +128,13 @@ func setupTestConnection(t *testing.T, config *Config) (
// Wire WriteMessage to push to outgoingData channel
mockSocket.WriteMessageFunc = func(msgType int, data []byte) error {
mockSocket.mu.Lock()
defer mockSocket.mu.Unlock()
select {
case outgoingData <- mockOutgoingData{msgType: msgType, data: data}:
return nil
case <-mockSocket.closed:
return io.EOF
default:
select {
case outgoingData <- mockOutgoingData{msgType: msgType, data: data}:
return nil
case <-mockSocket.closed:
return io.EOF
default:
return fmt.Errorf("mock outgoing chanel unavailable")
}
return fmt.Errorf("mock outgoing chanel unavailable")
}
}