MCPcopy
hub / github.com/cli/cli / TestListRun

Function TestListRun

pkg/cmd/repo/autolink/list/list_test.go:114–268  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

112}
113
114func TestListRun(t *testing.T) {
115 tests := []struct {
116 name string
117 opts *listOptions
118 isTTY bool
119 stubLister stubAutolinkLister
120 expectedErr error
121 wantStdout string
122 wantStderr string
123 }{
124 {
125 name: "list tty",
126 opts: &listOptions{},
127 isTTY: true,
128 stubLister: stubAutolinkLister{
129 autolinks: []shared.Autolink{
130 {
131 ID: 1,
132 KeyPrefix: "TICKET-",
133 URLTemplate: "https://example.com/TICKET?query=<num>",
134 IsAlphanumeric: true,
135 },
136 {
137 ID: 2,
138 KeyPrefix: "STORY-",
139 URLTemplate: "https://example.com/STORY?id=<num>",
140 IsAlphanumeric: false,
141 },
142 },
143 },
144 wantStdout: heredoc.Doc(`
145
146 Showing 2 autolink references in OWNER/REPO
147
148 ID KEY PREFIX URL TEMPLATE ALPHANUMERIC
149 1 TICKET- https://example.com/TICKET?query=<num> true
150 2 STORY- https://example.com/STORY?id=<num> false
151 `),
152 wantStderr: "",
153 },
154 {
155 name: "list json",
156 opts: &listOptions{
157 Exporter: func() cmdutil.Exporter {
158 exporter := cmdutil.NewJSONExporter()
159 exporter.SetFields([]string{"id"})
160 return exporter
161 }(),
162 },
163 isTTY: true,
164 stubLister: stubAutolinkLister{
165 autolinks: []shared.Autolink{
166 {
167 ID: 1,
168 KeyPrefix: "TICKET-",
169 URLTemplate: "https://example.com/TICKET?query=<num>",
170 IsAlphanumeric: true,
171 },

Callers

nothing calls this directly

Calls 13

NewJSONExporterFunction · 0.92
NewNoResultsErrorFunction · 0.92
TestFunction · 0.92
NewFunction · 0.92
SetFieldsMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
listRunFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected