MCPcopy Create free account
hub / github.com/astercloud/aster / TestForEach_Error

Function TestForEach_Error

pkg/stream/stream_test.go:371–385  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

369}
370
371func TestForEach_Error(t *testing.T) {
372 reader := FromSlice([]int{1, 2, 3, 4, 5})
373
374 customErr := errors.New("stop at 3")
375 err := ForEach(reader, func(v int) error {
376 if v == 3 {
377 return customErr
378 }
379 return nil
380 })
381
382 if !errors.Is(err, customErr) {
383 t.Errorf("expected custom error, got %v", err)
384 }
385}
386
387func TestErrorPropagation(t *testing.T) {
388 reader, writer := Pipe[int](2)

Callers

nothing calls this directly

Calls 2

FromSliceFunction · 0.85
ForEachFunction · 0.85

Tested by

no test coverage detected