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

Function TestNoRepoCanBeDetermined

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

Source from the content-addressed store, hash-verified

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

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