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

Function TestNewCmdListBaseRepoFuncs

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

Source from the content-addressed store, hash-verified

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