(t *testing.T)
| 2267 | } |
| 2268 | |
| 2269 | func TestNoRepoCanBeDetermined(t *testing.T) { |
| 2270 | // Given no head repo can be determined from git config |
| 2271 | cs, cmdTeardown := run.Stub() |
| 2272 | defer cmdTeardown(t) |
| 2273 | |
| 2274 | cs.Register(`git status --porcelain`, 0, "") |
| 2275 | cs.Register(`git config --get-regexp \^branch\\\..+\\\.\(remote\|merge\|pushremote\|gh-merge-base\)\$`, 0, "") |
| 2276 | cs.Register(`git rev-parse --symbolic-full-name feature@{push}`, 1, "") |
| 2277 | cs.Register("git config remote.pushDefault", 1, "") |
| 2278 | cs.Register("git config push.default", 1, "") |
| 2279 | |
| 2280 | // And Given there is no remote on the correct SHA |
| 2281 | cs.Register(`git show-ref --verify -- HEAD refs/remotes/origin/feature`, 0, heredoc.Doc(` |
| 2282 | deadbeef HEAD |
| 2283 | deadb00f refs/remotes/origin/feature`)) |
| 2284 | |
| 2285 | // When the command is run with no TTY |
| 2286 | reg := &httpmock.Registry{} |
| 2287 | reg.StubRepoInfoResponse("OWNER", "REPO", "master") |
| 2288 | defer reg.Verify(t) |
| 2289 | |
| 2290 | ios, _, _, stderr := iostreams.Test() |
| 2291 | |
| 2292 | opts := CreateOptions{ |
| 2293 | HttpClient: func() (*http.Client, error) { |
| 2294 | return &http.Client{Transport: reg}, nil |
| 2295 | }, |
| 2296 | Config: func() (gh.Config, error) { |
| 2297 | return config.NewBlankConfig(), nil |
| 2298 | }, |
| 2299 | Browser: &browser.Stub{}, |
| 2300 | IO: ios, |
| 2301 | Prompter: &prompter.PrompterMock{}, |
| 2302 | GitClient: &git.Client{ |
| 2303 | GhPath: "some/path/gh", |
| 2304 | GitPath: "some/path/git", |
| 2305 | }, |
| 2306 | Finder: shared.NewMockFinder("feature", nil, nil), |
| 2307 | Remotes: func() (context.Remotes, error) { |
| 2308 | return context.Remotes{ |
| 2309 | { |
| 2310 | Remote: &git.Remote{ |
| 2311 | Name: "origin", |
| 2312 | Resolved: "base", |
| 2313 | }, |
| 2314 | Repo: ghrepo.New("OWNER", "REPO"), |
| 2315 | }, |
| 2316 | }, nil |
| 2317 | }, |
| 2318 | Branch: func() (string, error) { |
| 2319 | return "feature", nil |
| 2320 | }, |
| 2321 | |
| 2322 | TitleProvided: true, |
| 2323 | BodyProvided: true, |
| 2324 | Title: "my title", |
| 2325 | Body: "my body", |
| 2326 | } |
nothing calls this directly
no test coverage detected