MCPcopy
hub / github.com/cli/cli / TestNewCmdSetBaseRepoFuncs

Function TestNewCmdSetBaseRepoFuncs

pkg/cmd/secret/set/set_test.go:285–418  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

283}
284
285func TestNewCmdSetBaseRepoFuncs(t *testing.T) {
286 multipleRemotes := ghContext.Remotes{
287 &ghContext.Remote{
288 Remote: &git.Remote{
289 Name: "origin",
290 },
291 Repo: ghrepo.New("owner", "fork"),
292 },
293 &ghContext.Remote{
294 Remote: &git.Remote{
295 Name: "upstream",
296 },
297 Repo: ghrepo.New("owner", "repo"),
298 },
299 }
300
301 singleRemote := ghContext.Remotes{
302 &ghContext.Remote{
303 Remote: &git.Remote{
304 Name: "origin",
305 },
306 Repo: ghrepo.New("owner", "repo"),
307 },
308 }
309
310 tests := []struct {
311 name string
312 args string
313 env map[string]string
314 remotes ghContext.Remotes
315 prompterStubs func(*prompter.MockPrompter)
316 wantRepo ghrepo.Interface
317 wantErr error
318 }{
319 {
320 name: "when there is a repo flag provided, the factory base repo func is used",
321 args: "SECRET_NAME --repo owner/repo",
322 remotes: multipleRemotes,
323 wantRepo: ghrepo.New("owner", "repo"),
324 },
325 {
326 name: "when GH_REPO env var is provided, the factory base repo func is used",
327 args: "SECRET_NAME",
328 env: map[string]string{
329 "GH_REPO": "owner/repo",
330 },
331 remotes: multipleRemotes,
332 wantRepo: ghrepo.New("owner", "repo"),
333 },
334 {
335 name: "when there is no repo flag or GH_REPO env var provided, and no prompting, the base func requiring no ambiguity is used",
336 args: "SECRET_NAME",
337 remotes: multipleRemotes,
338 wantErr: shared.AmbiguousBaseRepoError{
339 Remotes: multipleRemotes,
340 },
341 },
342 {

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

Tested by

no test coverage detected