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

Function TestParseRunArgs

script/ghmock/run_test.go:281–407  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

279}
280
281func TestParseRunArgs(t *testing.T) {
282 tests := []struct {
283 name string
284 args []string
285 want runOptions
286 wantErr string
287 }{
288 {
289 name: "one binary and gh arguments after --",
290 args: []string{"--gh", "./bin/gh", "--", "issue", "view", "1"},
291 want: runOptions{binaries: []string{"./bin/gh"}, timeout: time.Minute, args: []string{"issue", "view", "1"}},
292 },
293 {
294 name: "prepared worktree",
295 args: []string{"--gh", "a", "--in", "feature", "--", "repo", "sync"},
296 want: runOptions{binaries: []string{"a"}, in: "feature", timeout: time.Minute, args: []string{"repo", "sync"}},
297 },
298 {
299 name: "configuration fixture",
300 args: []string{"--gh", "a", "--config-dir", "fixtures/accounts", "--", "auth", "status"},
301 want: runOptions{binaries: []string{"a"}, configDir: "fixtures/accounts", timeout: time.Minute, args: []string{"auth", "status"}},
302 },
303 {
304 name: "empty configuration fixture path",
305 args: []string{"--gh", "a", "--config-dir", "", "--", "auth", "status"},
306 wantErr: "--config-dir needs a fixture directory",
307 },
308 {
309 name: "missing configuration fixture flag value",
310 args: []string{"--gh", "a", "--config-dir"},
311 wantErr: "flag needs an argument: -config-dir",
312 },
313 {
314 name: "configuration fixture conflicts with default logged-out state",
315 args: []string{"--gh", "a", "--config-dir", "fixtures/accounts", "--logged-out", "--", "auth", "status"},
316 wantErr: "--config-dir and --logged-out cannot be combined; use a fixture without hosts.yml for a logged-out run",
317 },
318 {
319 name: "outside fixture",
320 args: []string{"--gh", "a", "--in", "../other", "--", "repo", "sync"},
321 wantErr: "--in must be a relative path inside the Git workspace",
322 },
323 {
324 name: "every flag",
325 args: []string{"--gh", "a", "--gh", "b", "--tty", "--logged-out", "--localhost", "--stdin", "token", "--timeout", "5s", "--", "auth", "login"},
326 want: runOptions{
327 binaries: []string{"a", "b"},
328 tty: true,
329 stdin: "token",
330 loggedOut: true,
331 localhost: true,
332 timeout: 5 * time.Second,
333 args: []string{"auth", "login"},
334 },
335 },
336 {
337 name: "--keys runs gh in a terminal",
338 args: []string{"--gh", "a", "--keys", "my-repo{enter}", "--keys", "{down}{enter}", "--", "repo", "create"},

Callers

nothing calls this directly

Calls 3

parseRunArgsFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected