(t *testing.T)
| 113 | } |
| 114 | |
| 115 | func Test_deleteRun(t *testing.T) { |
| 116 | tests := []struct { |
| 117 | name string |
| 118 | tty bool |
| 119 | opts *DeleteOptions |
| 120 | httpStubs func(*httpmock.Registry) |
| 121 | prompterStubs func(*prompter.PrompterMock) |
| 122 | wantStdout string |
| 123 | wantStderr string |
| 124 | wantErr bool |
| 125 | errMsg string |
| 126 | }{ |
| 127 | { |
| 128 | name: "prompting confirmation tty", |
| 129 | tty: true, |
| 130 | opts: &DeleteOptions{RepoArg: "OWNER/REPO"}, |
| 131 | wantStdout: "✓ Deleted repository OWNER/REPO\n", |
| 132 | prompterStubs: func(p *prompter.PrompterMock) { |
| 133 | p.ConfirmDeletionFunc = func(_ string) error { |
| 134 | return nil |
| 135 | } |
| 136 | }, |
| 137 | httpStubs: func(reg *httpmock.Registry) { |
| 138 | reg.Register( |
| 139 | httpmock.REST("DELETE", "repos/OWNER/REPO"), |
| 140 | httpmock.StatusStringResponse(204, "{}")) |
| 141 | }, |
| 142 | }, |
| 143 | { |
| 144 | name: "infer base repo", |
| 145 | tty: true, |
| 146 | opts: &DeleteOptions{}, |
| 147 | wantStdout: "✓ Deleted repository OWNER/REPO\n", |
| 148 | prompterStubs: func(p *prompter.PrompterMock) { |
| 149 | p.ConfirmDeletionFunc = func(_ string) error { |
| 150 | return nil |
| 151 | } |
| 152 | }, |
| 153 | httpStubs: func(reg *httpmock.Registry) { |
| 154 | reg.Register( |
| 155 | httpmock.REST("DELETE", "repos/OWNER/REPO"), |
| 156 | httpmock.StatusStringResponse(204, "{}")) |
| 157 | }, |
| 158 | }, |
| 159 | { |
| 160 | name: "confirmation no tty", |
| 161 | opts: &DeleteOptions{ |
| 162 | RepoArg: "OWNER/REPO", |
| 163 | Confirmed: true, |
| 164 | }, |
| 165 | httpStubs: func(reg *httpmock.Registry) { |
| 166 | reg.Register( |
| 167 | httpmock.REST("DELETE", "repos/OWNER/REPO"), |
| 168 | httpmock.StatusStringResponse(204, "{}")) |
| 169 | }, |
| 170 | }, |
| 171 | { |
| 172 | name: "short repo name", |
nothing calls this directly
no test coverage detected