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

Function TestPrintSkip

pkg/cmd/issue/artifact/shared/results_test.go:71–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func TestPrintSkip(t *testing.T) {
72 tests := []struct {
73 name string
74 tty bool
75 color bool
76 result Result
77 subject string
78 reason string
79 wantStdout string
80 }{
81 {
82 name: "in a terminal, the skip goes to stdout",
83 tty: true,
84 result: Result{Number: 2, Name: "2-OAuth-callback-plan.md"},
85 subject: "2-OAuth-callback-plan.md",
86 reason: "already exists",
87 wantStdout: "- Skipped 2-OAuth-callback-plan.md: already exists\n",
88 },
89 {
90 name: "colors in a terminal",
91 tty: true,
92 color: true,
93 result: Result{Number: 2, Name: "2-OAuth-callback-plan.md"},
94 subject: "2-OAuth-callback-plan.md",
95 reason: "already exists",
96 wantStdout: "\x1b[38;5;242m-\x1b[0m Skipped 2-OAuth-callback-plan.md: already exists\n",
97 },
98 {
99 name: "piped, a skipped line with the reason",
100 result: Result{Number: 2, Name: "2-OAuth-callback-plan.md"},
101 subject: "2-OAuth-callback-plan.md",
102 reason: "already exists",
103 wantStdout: "skipped\t2\t2-OAuth-callback-plan.md\t\talready exists\n",
104 },
105 }
106
107 for _, tt := range tests {
108 t.Run(tt.name, func(t *testing.T) {
109 ios, _, stdout, stderr := iostreams.Test()
110 ios.SetStdinTTY(tt.tty)
111 ios.SetStdoutTTY(tt.tty)
112 ios.SetStderrTTY(tt.tty)
113 ios.SetColorEnabled(tt.color)
114
115 PrintSkip(ios, tt.result, tt.subject, tt.reason)
116
117 assert.Equal(t, tt.wantStdout, stdout.String())
118 assert.Equal(t, "", stderr.String())
119 })
120 }
121}
122
123func TestPrintUnchanged(t *testing.T) {
124 tests := []struct {

Callers

nothing calls this directly

Calls 9

TestFunction · 0.92
PrintSkipFunction · 0.85
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
SetColorEnabledMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected