(t *testing.T)
| 164 | } |
| 165 | |
| 166 | func Test_checkoutRun(t *testing.T) { |
| 167 | tests := []struct { |
| 168 | name string |
| 169 | opts *CheckoutOptions |
| 170 | |
| 171 | httpStubs func(*httpmock.Registry) |
| 172 | runStubs func(*run.CommandStubber) |
| 173 | promptStubs func(*prompter.MockPrompter) |
| 174 | |
| 175 | remotes map[string]string |
| 176 | wantStdout string |
| 177 | wantStderr string |
| 178 | wantErr bool |
| 179 | errMsg string |
| 180 | }{ |
| 181 | { |
| 182 | name: "checkout with ssh remote URL", |
| 183 | opts: &CheckoutOptions{ |
| 184 | PRResolver: func() PRResolver { |
| 185 | baseRepo, pr := stubPR("OWNER/REPO:master", "OWNER/REPO:feature") |
| 186 | return &stubPRResolver{ |
| 187 | pr: pr, |
| 188 | baseRepo: baseRepo, |
| 189 | } |
| 190 | }(), |
| 191 | Config: func() (gh.Config, error) { |
| 192 | return config.NewBlankConfig(), nil |
| 193 | }, |
| 194 | Branch: func() (string, error) { |
| 195 | return "main", nil |
| 196 | }, |
| 197 | }, |
| 198 | remotes: map[string]string{ |
| 199 | "origin": "OWNER/REPO", |
| 200 | }, |
| 201 | runStubs: func(cs *run.CommandStubber) { |
| 202 | cs.Register(`git show-ref --verify -- refs/heads/feature`, 1, "") |
| 203 | cs.Register(`git fetch origin \+refs/heads/feature:refs/remotes/origin/feature --no-tags`, 0, "") |
| 204 | cs.Register(`git checkout -b feature --track origin/feature`, 0, "") |
| 205 | }, |
| 206 | }, |
| 207 | { |
| 208 | name: "fork repo was deleted", |
| 209 | opts: &CheckoutOptions{ |
| 210 | PRResolver: func() PRResolver { |
| 211 | baseRepo, pr := stubPR("OWNER/REPO:master", "OWNER/REPO:feature") |
| 212 | pr.MaintainerCanModify = true |
| 213 | pr.HeadRepository = nil |
| 214 | return &stubPRResolver{ |
| 215 | pr: pr, |
| 216 | baseRepo: baseRepo, |
| 217 | } |
| 218 | }(), |
| 219 | Config: func() (gh.Config, error) { |
| 220 | return config.NewBlankConfig(), nil |
| 221 | }, |
| 222 | Branch: func() (string, error) { |
| 223 | return "main", nil |
nothing calls this directly
no test coverage detected