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

Function TestStdoutSendsPipeContentsToConfiguredStandardOutput

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

Source from the content-addressed store, hash-verified

1453}
1454
1455func TestStdoutSendsPipeContentsToConfiguredStandardOutput(t *testing.T) {
1456 t.Parallel()
1457 buf := new(bytes.Buffer)
1458 want := "hello world"
1459 p := script.File("testdata/hello.txt").WithStdout(buf)
1460 wrote, err := p.Stdout()
1461 if err != nil {
1462 t.Fatal(err)
1463 }
1464 if wrote != len(want) {
1465 t.Fatalf("want %d bytes written, got %d", len(want), wrote)
1466 }
1467 got := buf.String()
1468 if want != got {
1469 t.Fatalf("want %q, got %q", want, string(got))
1470 }
1471 _, err = p.String()
1472 if err == nil {
1473 t.Error("input not closed after reading")
1474 }
1475}
1476
1477func TestAppendFile_AppendsAllItsInputToSpecifiedFile(t *testing.T) {
1478 t.Parallel()

Callers

nothing calls this directly

Calls 5

FileFunction · 0.92
WithStdoutMethod · 0.80
StdoutMethod · 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…