MCPcopy Create free account
hub / github.com/compozy/agh / executeRootCommandWithInput

Function executeRootCommandWithInput

internal/cli/tool_test.go:1007–1025  ·  view source on GitHub ↗
(
	t *testing.T,
	deps commandDeps,
	stdin string,
	args ...string,
)

Source from the content-addressed store, hash-verified

1005}
1006
1007func executeRootCommandWithInput(
1008 t *testing.T,
1009 deps commandDeps,
1010 stdin string,
1011 args ...string,
1012) (string, string, error) {
1013 t.Helper()
1014
1015 cmd := newRootCommand(deps)
1016 var stdout bytes.Buffer
1017 var stderr bytes.Buffer
1018 cmd.SetOut(&stdout)
1019 cmd.SetErr(&stderr)
1020 cmd.SetIn(strings.NewReader(stdin))
1021 cmd.SetArgs(args)
1022
1023 err := cmd.ExecuteContext(t.Context())
1024 return stdout.String(), stderr.String(), err
1025}
1026
1027func decodeJSONOutput(t *testing.T, stdout string, target any) {
1028 t.Helper()

Callers 1

Calls 2

newRootCommandFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected