MCPcopy
hub / github.com/github/git-sizer / TestPipelineWithFunction

Function TestPipelineWithFunction

internal/pipe/pipeline_test.go:382–409  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

380}
381
382func TestPipelineWithFunction(t *testing.T) {
383 t.Parallel()
384 ctx := context.Background()
385
386 p := pipe.New()
387 p.Add(
388 pipe.Command("echo", "-n", "hello world"),
389 pipe.Function(
390 "farewell",
391 func(_ context.Context, _ pipe.Env, stdin io.Reader, stdout io.Writer) error {
392 buf, err := io.ReadAll(stdin)
393 if err != nil {
394 return err
395 }
396 if string(buf) != "hello world" {
397 return fmt.Errorf("expected \"hello world\"; got %q", string(buf))
398 }
399 _, err = stdout.Write([]byte("goodbye, cruel world"))
400 return err
401 },
402 ),
403 pipe.Command("tr", "a-z", "A-Z"),
404 )
405
406 out, err := p.Output(ctx)
407 assert.NoError(t, err)
408 assert.EqualValues(t, "GOODBYE, CRUEL WORLD", out)
409}
410
411type ErrorStartingStage struct {
412 err error

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
CommandFunction · 0.92
FunctionFunction · 0.92
OutputMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected