MCPcopy
hub / github.com/cli/cli / TestChecksRun_web

Function TestChecksRun_web

pkg/cmd/pr/checks/checks_test.go:619–667  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

617}
618
619func TestChecksRun_web(t *testing.T) {
620 tests := []struct {
621 name string
622 isTTY bool
623 wantStderr string
624 wantStdout string
625 wantBrowse string
626 }{
627 {
628 name: "tty",
629 isTTY: true,
630 wantStderr: "Opening https://github.com/OWNER/REPO/pull/123/checks in your browser.\n",
631 wantStdout: "",
632 wantBrowse: "https://github.com/OWNER/REPO/pull/123/checks",
633 },
634 {
635 name: "nontty",
636 isTTY: false,
637 wantStderr: "",
638 wantStdout: "",
639 wantBrowse: "https://github.com/OWNER/REPO/pull/123/checks",
640 },
641 }
642 for _, tc := range tests {
643 t.Run(tc.name, func(t *testing.T) {
644 browser := &browser.Stub{}
645
646 ios, _, stdout, stderr := iostreams.Test()
647 ios.SetStdoutTTY(tc.isTTY)
648 ios.SetStdinTTY(tc.isTTY)
649 ios.SetStderrTTY(tc.isTTY)
650
651 _, teardown := run.Stub()
652 defer teardown(t)
653
654 err := checksRunWebMode(&ChecksOptions{
655 IO: ios,
656 Browser: browser,
657 WebMode: true,
658 SelectorArg: "123",
659 Finder: shared.NewMockFinder("123", &api.PullRequest{Number: 123}, ghrepo.New("OWNER", "REPO")),
660 })
661 assert.NoError(t, err)
662 assert.Equal(t, tc.wantStdout, stdout.String())
663 assert.Equal(t, tc.wantStderr, stderr.String())
664 browser.Verify(t, tc.wantBrowse)
665 })
666 }
667}
668
669func TestEliminateDuplicates(t *testing.T) {
670 tests := []struct {

Callers

nothing calls this directly

Calls 12

VerifyMethod · 0.95
TestFunction · 0.92
StubFunction · 0.92
NewMockFinderFunction · 0.92
NewFunction · 0.92
checksRunWebModeFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected