MCPcopy
hub / github.com/cli/cli / TestNewCmdDeleteBaseRepoFuncs

Function TestNewCmdDeleteBaseRepoFuncs

pkg/cmd/secret/delete/delete_test.go:145–278  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

143}
144
145func TestNewCmdDeleteBaseRepoFuncs(t *testing.T) {
146 multipleRemotes := ghContext.Remotes{
147 &ghContext.Remote{
148 Remote: &git.Remote{
149 Name: "origin",
150 },
151 Repo: ghrepo.New("owner", "fork"),
152 },
153 &ghContext.Remote{
154 Remote: &git.Remote{
155 Name: "upstream",
156 },
157 Repo: ghrepo.New("owner", "repo"),
158 },
159 }
160
161 singleRemote := ghContext.Remotes{
162 &ghContext.Remote{
163 Remote: &git.Remote{
164 Name: "origin",
165 },
166 Repo: ghrepo.New("owner", "repo"),
167 },
168 }
169
170 tests := []struct {
171 name string
172 args string
173 env map[string]string
174 remotes ghContext.Remotes
175 prompterStubs func(*prompter.MockPrompter)
176 wantRepo ghrepo.Interface
177 wantErr error
178 }{
179 {
180 name: "when there is a repo flag provided, the factory base repo func is used",
181 args: "SECRET_NAME --repo owner/repo",
182 remotes: multipleRemotes,
183 wantRepo: ghrepo.New("owner", "repo"),
184 },
185 {
186 name: "when GH_REPO env var is provided, the factory base repo func is used",
187 args: "SECRET_NAME",
188 env: map[string]string{
189 "GH_REPO": "owner/repo",
190 },
191 remotes: multipleRemotes,
192 wantRepo: ghrepo.New("owner", "repo"),
193 },
194 {
195 name: "when there is no repo flag or GH_REPO env var provided, and no prompting, the base func requiring no ambiguity is used",
196 args: "SECRET_NAME",
197 remotes: multipleRemotes,
198 wantErr: shared.AmbiguousBaseRepoError{
199 Remotes: multipleRemotes,
200 },
201 },
202 {

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
NewCmdDeleteFunction · 0.70

Tested by

no test coverage detected