(t *testing.T)
| 123 | var errTestAutolinkClientDelete = errors.New("autolink client delete error") |
| 124 | |
| 125 | func TestDeleteRun(t *testing.T) { |
| 126 | tests := []struct { |
| 127 | name string |
| 128 | opts *deleteOptions |
| 129 | isTTY bool |
| 130 | stubDeleter stubAutolinkDeleter |
| 131 | stubViewer stubAutolinkViewer |
| 132 | prompterStubs func(*prompter.PrompterMock) |
| 133 | |
| 134 | wantStdout string |
| 135 | expectedErr error |
| 136 | expectedErrMsg string |
| 137 | }{ |
| 138 | { |
| 139 | name: "delete", |
| 140 | opts: &deleteOptions{ |
| 141 | ID: "123", |
| 142 | }, |
| 143 | isTTY: true, |
| 144 | stubViewer: stubAutolinkViewer{ |
| 145 | autolink: &shared.Autolink{ |
| 146 | ID: 123, |
| 147 | KeyPrefix: "TICKET-", |
| 148 | URLTemplate: "https://example.com/TICKET?query=<num>", |
| 149 | IsAlphanumeric: true, |
| 150 | }, |
| 151 | }, |
| 152 | stubDeleter: stubAutolinkDeleter{ |
| 153 | err: nil, |
| 154 | }, |
| 155 | prompterStubs: func(pm *prompter.PrompterMock) { |
| 156 | pm.ConfirmDeletionFunc = func(_ string) error { |
| 157 | return nil |
| 158 | } |
| 159 | }, |
| 160 | wantStdout: heredoc.Doc(` |
| 161 | Autolink 123 has key prefix TICKET-. |
| 162 | ✓ Autolink 123 deleted from OWNER/REPO |
| 163 | `), |
| 164 | }, |
| 165 | { |
| 166 | name: "delete with confirm flag", |
| 167 | opts: &deleteOptions{ |
| 168 | ID: "123", |
| 169 | Confirmed: true, |
| 170 | }, |
| 171 | isTTY: true, |
| 172 | stubViewer: stubAutolinkViewer{ |
| 173 | autolink: &shared.Autolink{ |
| 174 | ID: 123, |
| 175 | KeyPrefix: "TICKET-", |
| 176 | URLTemplate: "https://example.com/TICKET?query=<num>", |
| 177 | IsAlphanumeric: true, |
| 178 | }, |
| 179 | }, |
| 180 | stubDeleter: stubAutolinkDeleter{}, |
| 181 | wantStdout: "✓ Autolink 123 deleted from OWNER/REPO\n", |
| 182 | }, |
nothing calls this directly
no test coverage detected