MCPcopy
hub / github.com/cli/cli / TestOfficialExtensionStubRun

Function TestOfficialExtensionStubRun

pkg/cmd/root/official_extension_stub_test.go:15–128  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestOfficialExtensionStubRun(t *testing.T) {
16 ext := &extensions.OfficialExtension{Name: "cool", Owner: "github", Repo: "gh-cool"}
17
18 tests := []struct {
19 name string
20 isTTY bool
21 ciEnv string
22 confirmResult bool
23 confirmErr error
24 installErr error
25 wantErr string
26 wantStderr string
27 wantInstalled bool
28 }{
29 {
30 name: "non-TTY in CI auto-installs without prompting",
31 isTTY: false,
32 ciEnv: "1",
33 wantStderr: "Successfully installed github/gh-cool",
34 wantInstalled: true,
35 },
36 {
37 name: "non-TTY outside CI prints install instructions and returns silent error",
38 isTTY: false,
39 wantStderr: "gh extension install github/gh-cool",
40 wantErr: "SilentError",
41 },
42 {
43 name: "TTY confirmed installs",
44 isTTY: true,
45 confirmResult: true,
46 wantStderr: "Successfully installed github/gh-cool",
47 wantInstalled: true,
48 },
49 {
50 name: "TTY in CI auto-installs without prompting",
51 isTTY: true,
52 ciEnv: "1",
53 wantStderr: "Successfully installed github/gh-cool",
54 wantInstalled: true,
55 },
56 {
57 name: "TTY declined does not install",
58 isTTY: true,
59 confirmResult: false,
60 },
61 {
62 name: "TTY prompt error is propagated",
63 isTTY: true,
64 confirmErr: fmt.Errorf("prompt interrupted"),
65 wantErr: "prompt interrupted",
66 },
67 {
68 name: "TTY install error is propagated",
69 isTTY: true,
70 confirmResult: true,
71 installErr: fmt.Errorf("network error"),
72 wantErr: "network error",

Callers

nothing calls this directly

Calls 15

InstallCallsMethod · 0.95
TestFunction · 0.92
officialExtensionStubRunFunction · 0.85
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
ContainsMethod · 0.80
EqualMethod · 0.80
ErrorfMethod · 0.65
RunMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65

Tested by

no test coverage detected