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

Function TestRunAll

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

Source from the content-addressed store, hash-verified

407}
408
409func TestRunAll(t *testing.T) {
410 const fixtureConfig = "version: \"1\"\ngit_protocol: ssh\n"
411 const fixtureHosts = "github.com:\n user: alice\n oauth_token: gho_ghmock-alice\n users:\n alice:\n oauth_token: gho_ghmock-alice\n bob:\n oauth_token: gho_ghmock-bob\n"
412 fixtureOutput := fmt.Sprintf("GH_CONFIG_DIR=<config>\nconfig.yml=%q\nhosts.yml=%q\nprobe.txt=(none)\n", fixtureConfig, fixtureHosts)
413
414 // resultSummary is the part of a run result that tests compare.
415 type resultSummary struct {
416 Version string
417 ExitCode int
418 TimedOut bool
419 Stdout string
420 Stderr string
421 Requests []logSummary
422 Steps []terminalStep
423 UnusedKeys int
424 }
425
426 tests := []struct {
427 name string
428 variants []string
429 responses responseSet
430 checkSchemas bool
431 // builds sets buildsDir: "own" is the folder holding the fake gh,
432 // and "other" is a different folder.
433 builds string
434 opts runOptions
435 want []resultSummary
436 wantCommand string
437 wantErr string
438 wantErrContains string
439 afterAPI bool
440 resolveOnly bool
441 setup func(*testing.T, *state)
442 check func(*testing.T, *state, runRecord)
443 }{
444 {
445 name: "a request-free command replaces the last run selection",
446 variants: []string{"a"},
447 responses: responseSet{"GET /user": {{Body: json.RawMessage(`{}`)}}},
448 opts: runOptions{args: []string{"--version"}},
449 want: []resultSummary{{Version: "gh version 0.0.0-a", Stdout: "gh version 0.0.0-a\n"}},
450 afterAPI: true,
451 },
452 {
453 name: "PATH executable lookup uses platform permission rules",
454 resolveOnly: true,
455 },
456 {
457 name: "direct command display preserves shell quoting",
458 variants: []string{"a"},
459 opts: runOptions{args: []string{"stdin", "two words", "it's", "", "$HOME"}, stdin: "observed\n"},
460 wantCommand: `ghmock run --gh <gh-a> --stdin 'observed
461' --timeout 30s -- stdin 'two words' 'it'\''s' '' '$HOME'`,
462 want: []resultSummary{{Version: "gh version 0.0.0-a", Stdout: "observed\n"}},
463 check: func(t *testing.T, st *state, rec runRecord) {
464 assert.Contains(t, rec.Report, "$ gh stdin 'two words' 'it'\\''s' '' '$HOME'\n")
465 },
466 },

Callers

nothing calls this directly

Calls 15

saveResponsesMethod · 0.95
readLogMethod · 0.95
readRunsMethod · 0.95
writeConfigFixtureFunction · 0.85
readFunction · 0.85
cmdExportFunction · 0.85
extractTestArchiveFunction · 0.85
cmdResetFunction · 0.85
prepareGitRepoFunction · 0.85
gitForTestFunction · 0.85
cmdWriteFunction · 0.85
resolveBinaryFunction · 0.85

Tested by

no test coverage detected