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

Function TestCancel

pkg/streamclient/stream_test.go:195–226  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

193}
194
195func TestCancel(t *testing.T) {
196 transport := newFakeTransport()
197
198 reader := NewReader("1", 1024, transport)
199 writer := NewWriter("1", 1024, transport)
200
201 go func() {
202 for dataPk := range transport.dataChan {
203 reader.RecvData(dataPk)
204 }
205 }()
206
207 go func() {
208 for ackPk := range transport.ackChan {
209 writer.RecvAck(ackPk)
210 }
211 }()
212
213 reader.Close()
214
215 select {
216 case <-writer.GetCanceledChan():
217 // Success
218 case <-time.After(1 * time.Second):
219 t.Fatal("Writer not notified of cancellation")
220 }
221
222 _, _, canceled := writer.GetAckState()
223 if !canceled {
224 t.Fatal("Writer should be in canceled state")
225 }
226}
227
228func TestMultipleWrites(t *testing.T) {
229 transport := newFakeTransport()

Callers

nothing calls this directly

Calls 8

RecvDataMethod · 0.95
RecvAckMethod · 0.95
CloseMethod · 0.95
GetCanceledChanMethod · 0.95
GetAckStateMethod · 0.95
newFakeTransportFunction · 0.85
NewReaderFunction · 0.85
NewWriterFunction · 0.85

Tested by

no test coverage detected