MCPcopy
hub / github.com/cli/cli / TestNoRepoCanBeDetermined

Function TestNoRepoCanBeDetermined

pkg/cmd/pr/create/create_test.go:2269–2334  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2267}
2268
2269func 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 }

Callers

nothing calls this directly

Calls 11

StubRepoInfoResponseMethod · 0.95
VerifyMethod · 0.95
StubFunction · 0.92
TestFunction · 0.92
NewBlankConfigFunction · 0.92
NewMockFinderFunction · 0.92
NewFunction · 0.92
EqualMethod · 0.80
createRunFunction · 0.70
RegisterMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected