MCPcopy
hub / github.com/bitfield/script / TestFilterByFirstLineOnlyGivesFirstLineOfInput

Function TestFilterByFirstLineOnlyGivesFirstLineOfInput

script_test.go:448–466  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

446}
447
448func TestFilterByFirstLineOnlyGivesFirstLineOfInput(t *testing.T) {
449 t.Parallel()
450 p := script.Echo("hello\nworld").Filter(func(r io.Reader, w io.Writer) error {
451 scanner := bufio.NewScanner(r)
452 for scanner.Scan() {
453 fmt.Fprintln(w, scanner.Text())
454 break
455 }
456 return scanner.Err()
457 })
458 want := "hello\n"
459 got, err := p.String()
460 if err != nil {
461 t.Fatal(err)
462 }
463 if want != got {
464 t.Error(cmp.Diff(want, got))
465 }
466}
467
468func TestFilterSetsErrorOnPipeIfFilterFuncReturnsError(t *testing.T) {
469 t.Parallel()

Callers

nothing calls this directly

Calls 4

EchoFunction · 0.92
FilterMethod · 0.80
StringMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…