MCPcopy
hub / github.com/cli/cli / TestNewCmdListBaseRepoFuncs

Function TestNewCmdListBaseRepoFuncs

pkg/cmd/secret/list/list_test.go:123–255  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

121}
122
123func TestNewCmdListBaseRepoFuncs(t *testing.T) {
124 multipleRemotes := ghContext.Remotes{
125 &ghContext.Remote{
126 Remote: &git.Remote{
127 Name: "origin",
128 },
129 Repo: ghrepo.New("owner", "fork"),
130 },
131 &ghContext.Remote{
132 Remote: &git.Remote{
133 Name: "upstream",
134 },
135 Repo: ghrepo.New("owner", "repo"),
136 },
137 }
138
139 singleRemote := ghContext.Remotes{
140 &ghContext.Remote{
141 Remote: &git.Remote{
142 Name: "origin",
143 },
144 Repo: ghrepo.New("owner", "repo"),
145 },
146 }
147
148 tests := []struct {
149 name string
150 args string
151 env map[string]string
152 remotes ghContext.Remotes
153 prompterStubs func(*prompter.MockPrompter)
154 wantRepo ghrepo.Interface
155 wantErr error
156 }{
157 {
158 name: "when there is a repo flag provided, the factory base repo func is used",
159 args: "--repo owner/repo",
160 remotes: multipleRemotes,
161 wantRepo: ghrepo.New("owner", "repo"),
162 },
163 {
164 name: "when GH_REPO env var is provided, the factory base repo func is used",
165 env: map[string]string{
166 "GH_REPO": "owner/repo",
167 },
168 remotes: multipleRemotes,
169 wantRepo: ghrepo.New("owner", "repo"),
170 },
171 {
172 name: "when there is no repo flag or GH_REPO env var provided, and no prompting, the base func requiring no ambiguity is used",
173 args: "",
174 remotes: multipleRemotes,
175 wantErr: shared.AmbiguousBaseRepoError{
176 Remotes: multipleRemotes,
177 },
178 },
179 {
180 name: "when there is no repo flag or GH_REPO env provided, and there is a single remote, the factory base repo func is used",

Callers

nothing calls this directly

Calls 14

NewFunction · 0.92
IndexForFunction · 0.92
TestFunction · 0.92
NewMockPrompterFunction · 0.92
FromFullNameFunction · 0.92
EnableRepoOverrideFunction · 0.92
IsSameFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
NewCmdListFunction · 0.70

Tested by

no test coverage detected