MCPcopy
hub / github.com/cli/cli / TestRunCopilot_execFailureHint

Function TestRunCopilot_execFailureHint

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

Source from the content-addressed store, hash-verified

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