(t *testing.T)
| 154 | } |
| 155 | |
| 156 | func Test_deleteRun(t *testing.T) { |
| 157 | tests := []struct { |
| 158 | name string |
| 159 | tty bool |
| 160 | opts *DeleteOptions |
| 161 | httpStubs func(*httpmock.Registry) |
| 162 | prompterStubs func(*prompter.PrompterMock) |
| 163 | wantConfirmPrompt string |
| 164 | wantConfirmDeletion string |
| 165 | wantStdout string |
| 166 | wantStderr string |
| 167 | wantErr bool |
| 168 | errMsg string |
| 169 | wantScopesSuggestion string |
| 170 | }{ |
| 171 | { |
| 172 | name: "prompting confirmation tty", |
| 173 | tty: true, |
| 174 | opts: &DeleteOptions{RepoArg: "OWNER/REPO"}, |
| 175 | wantConfirmDeletion: "OWNER/REPO", |
| 176 | wantStdout: "✓ Deleted repository OWNER/REPO\n", |
| 177 | prompterStubs: func(p *prompter.PrompterMock) { |
| 178 | p.ConfirmDeletionFunc = func(_ string) error { |
| 179 | return nil |
| 180 | } |
| 181 | }, |
| 182 | httpStubs: func(reg *httpmock.Registry) { |
| 183 | reg.Register( |
| 184 | httpmock.REST("GET", "repos/OWNER/REPO"), |
| 185 | httpmock.StringResponse(`{"private":false,"fork":false,"forks_count":0}`)) |
| 186 | reg.Register( |
| 187 | httpmock.REST("DELETE", "repos/OWNER/REPO"), |
| 188 | httpmock.StatusStringResponse(204, "{}")) |
| 189 | }, |
| 190 | }, |
| 191 | { |
| 192 | name: "infer base repo", |
| 193 | tty: true, |
| 194 | opts: &DeleteOptions{}, |
| 195 | wantConfirmDeletion: "OWNER/REPO", |
| 196 | wantStdout: "✓ Deleted repository OWNER/REPO\n", |
| 197 | prompterStubs: func(p *prompter.PrompterMock) { |
| 198 | p.ConfirmDeletionFunc = func(_ string) error { |
| 199 | return nil |
| 200 | } |
| 201 | }, |
| 202 | httpStubs: func(reg *httpmock.Registry) { |
| 203 | reg.Register( |
| 204 | httpmock.REST("GET", "repos/OWNER/REPO"), |
| 205 | httpmock.StringResponse(`{"private":false,"fork":false,"forks_count":0}`)) |
| 206 | reg.Register( |
| 207 | httpmock.REST("DELETE", "repos/OWNER/REPO"), |
| 208 | httpmock.StatusStringResponse(204, "{}")) |
| 209 | }, |
| 210 | }, |
| 211 | { |
| 212 | name: "confirmation no tty", |
| 213 | opts: &DeleteOptions{ |
nothing calls this directly
no test coverage detected