(t *testing.T)
| 112 | } |
| 113 | |
| 114 | func Test_viewRun(t *testing.T) { |
| 115 | tests := []struct { |
| 116 | name string |
| 117 | opts *ViewOptions |
| 118 | wantOut string |
| 119 | mockGist *shared.Gist |
| 120 | mockGistList bool |
| 121 | isTTY bool |
| 122 | wantErr string |
| 123 | }{ |
| 124 | { |
| 125 | name: "no such gist", |
| 126 | isTTY: false, |
| 127 | opts: &ViewOptions{ |
| 128 | Selector: "1234", |
| 129 | ListFiles: false, |
| 130 | }, |
| 131 | wantErr: "not found", |
| 132 | }, |
| 133 | { |
| 134 | name: "one file", |
| 135 | isTTY: true, |
| 136 | opts: &ViewOptions{ |
| 137 | Selector: "1234", |
| 138 | ListFiles: false, |
| 139 | }, |
| 140 | mockGist: &shared.Gist{ |
| 141 | Files: map[string]*shared.GistFile{ |
| 142 | "cicada.txt": { |
| 143 | Content: "bwhiizzzbwhuiiizzzz", |
| 144 | Type: "text/plain", |
| 145 | }, |
| 146 | }, |
| 147 | }, |
| 148 | wantOut: "bwhiizzzbwhuiiizzzz\n", |
| 149 | }, |
| 150 | { |
| 151 | name: "one file, no ID supplied", |
| 152 | isTTY: true, |
| 153 | opts: &ViewOptions{ |
| 154 | Selector: "", |
| 155 | ListFiles: false, |
| 156 | }, |
| 157 | mockGistList: true, |
| 158 | mockGist: &shared.Gist{ |
| 159 | Files: map[string]*shared.GistFile{ |
| 160 | "cicada.txt": { |
| 161 | Content: "test interactive mode", |
| 162 | Type: "text/plain", |
| 163 | }, |
| 164 | }, |
| 165 | }, |
| 166 | wantOut: "test interactive mode\n", |
| 167 | }, |
| 168 | { |
| 169 | name: "no arguments notty", |
| 170 | isTTY: false, |
| 171 | wantErr: "gist ID or URL required when not running interactively", |
nothing calls this directly
no test coverage detected