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

Function TestNoRepoCanBeDetermined

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

Source from the content-addressed store, hash-verified

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

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