MCPcopy Create free account
hub / github.com/cli/cli / TestNoRepoCanBeDetermined

Function TestNoRepoCanBeDetermined

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

Source from the content-addressed store, hash-verified

2728}
2729
2730func TestNoRepoCanBeDetermined(t *testing.T) {
2731 // Given no head repo can be determined from git config
2732 cs, cmdTeardown := run.Stub()
2733 defer cmdTeardown(t)
2734
2735 cs.Register(`git status --porcelain`, 0, "")
2736 cs.Register(`git config --get-regexp \^branch\\\..+\\\.\(remote\|merge\|pushremote\|gh-merge-base\)\$`, 0, "")
2737 cs.Register(`git rev-parse --symbolic-full-name feature@{push}`, 1, "")
2738 cs.Register("git config remote.pushDefault", 1, "")
2739 cs.Register("git config push.default", 1, "")
2740
2741 // And Given there is no remote on the correct SHA
2742 cs.Register(`git show-ref --verify -- HEAD refs/remotes/origin/feature`, 0, heredoc.Doc(`
2743 deadbeef HEAD
2744 deadb00f refs/remotes/origin/feature`))
2745
2746 // When the command is run with no TTY
2747 reg := &httpmock.Registry{}
2748 reg.StubRepoInfoResponse("OWNER", "REPO", "master")
2749 defer reg.Verify(t)
2750
2751 ios, _, _, stderr := iostreams.Test()
2752
2753 opts := CreateOptions{
2754 HttpClient: func() (*http.Client, error) {
2755 return &http.Client{Transport: reg}, nil
2756 },
2757 Config: func() (gh.Config, error) {
2758 return config.NewMockConfig(), nil
2759 },
2760 Browser: &browser.Stub{},
2761 IO: ios,
2762 Prompter: &prompter.PrompterMock{},
2763 GitClient: &git.Client{
2764 GhPath: "some/path/gh",
2765 GitPath: "some/path/git",
2766 },
2767 Finder: shared.NewMockFinder("feature", nil, nil),
2768 Remotes: func() (context.Remotes, error) {
2769 return context.Remotes{
2770 {
2771 Remote: &git.Remote{
2772 Name: "origin",
2773 Resolved: "base",
2774 },
2775 Repo: ghrepo.New("OWNER", "REPO"),
2776 },
2777 }, nil
2778 },
2779 Branch: func() (string, error) {
2780 return "feature", nil
2781 },
2782
2783 TitleProvided: true,
2784 BodyProvided: true,
2785 Title: "my title",
2786 Body: "my body",
2787 }

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected