MCPcopy Create free account
hub / github.com/cli/cli / TestRunCopilot_execFailureHint

Function TestRunCopilot_execFailureHint

pkg/cmd/copilot/copilot_test.go:594–618  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

592}
593
594func TestRunCopilot_execFailureHint(t *testing.T) {
595 ios, _, _, _ := iostreams.Test()
596 opts := &CopilotOptions{
597 IO: ios,
598 CopilotArgs: []string{},
599 }
600
601 origFind := findCopilotBinaryFunc
602 findCopilotBinaryFunc = func() string {
603 return "/usr/bin/copilot"
604 }
605 t.Cleanup(func() { findCopilotBinaryFunc = origFind })
606
607 execErr := fmt.Errorf("exec failed: something went wrong")
608 origRun := runExternalCmdFunc
609 runExternalCmdFunc = func(_ *exec.Cmd) error {
610 return execErr
611 }
612 t.Cleanup(func() { runExternalCmdFunc = origRun })
613
614 err := runCopilot(opts)
615 require.Error(t, err)
616 require.ErrorIs(t, err, execErr)
617 require.Contains(t, err.Error(), "try running `copilot` directly without `gh`.")
618}
619
620func TestCopilotCommandIsSampledAt100(t *testing.T) {
621 spy := &telemetry.CommandRecorderSpy{}

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
runCopilotFunction · 0.85
ContainsMethod · 0.80
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected