(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: "truncated raw file with escape sequences is sanitized on a terminal", |
| 152 | isTTY: true, |
| 153 | opts: &ViewOptions{ |
| 154 | Selector: "1234", |
| 155 | ListFiles: false, |
| 156 | }, |
| 157 | mockGist: &shared.Gist{ |
| 158 | Files: map[string]*shared.GistFile{ |
| 159 | "escaped.txt": { |
| 160 | Type: "text/plain", |
| 161 | Content: "", |
| 162 | Truncated: true, |
| 163 | RawURL: "https://gist.githubusercontent.com/user/1234/raw/escaped.txt", |
| 164 | }, |
| 165 | }, |
| 166 | }, |
| 167 | wantOut: "danger^[[31m\n", |
| 168 | }, |
| 169 | { |
| 170 | name: "piped truncated raw file with escape sequences is refused", |
| 171 | isTTY: false, |
nothing calls this directly
no test coverage detected