MCPcopy
hub / github.com/wavetermdev/waveterm / TestBrokerError

Function TestBrokerError

pkg/streamclient/streambroker_test.go:179–199  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

177}
178
179func TestBrokerError(t *testing.T) {
180 broker1, broker2 := setupBrokerPair()
181
182 reader, meta := broker1.CreateStreamReader("reader1", "writer1", 1024)
183 writer, err := broker2.CreateStreamWriter(meta)
184 if err != nil {
185 t.Fatalf("CreateStreamWriter failed: %v", err)
186 }
187
188 testErr := io.ErrUnexpectedEOF
189 writer.CloseWithError(testErr)
190
191 buf := make([]byte, 1024)
192 _, err = reader.Read(buf)
193 if err == nil {
194 t.Fatal("Expected error from read")
195 }
196 if err.Error() != "stream error: unexpected EOF" {
197 t.Fatalf("Expected stream error, got: %v", err)
198 }
199}
200
201func TestBrokerCancel(t *testing.T) {
202 broker1, broker2 := setupBrokerPair()

Callers

nothing calls this directly

Calls 6

setupBrokerPairFunction · 0.85
CreateStreamReaderMethod · 0.80
CreateStreamWriterMethod · 0.80
CloseWithErrorMethod · 0.80
ReadMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected