(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func 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", |
nothing calls this directly
no test coverage detected