MCPcopy
hub / github.com/cli/cli / TestIssueExportData

Function TestIssueExportData

pkg/search/result_test.go:131–197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

129}
130
131func TestIssueExportData(t *testing.T) {
132 var updatedAt = time.Date(2021, 2, 28, 12, 30, 0, 0, time.UTC)
133 trueValue := true
134 tests := []struct {
135 name string
136 fields []string
137 issue Issue
138 output string
139 }{
140 {
141 name: "exports requested fields",
142 fields: []string{"assignees", "body", "commentsCount", "labels", "isLocked", "repository", "title", "updatedAt"},
143 issue: Issue{
144 Assignees: []User{{Login: "test", ID: "123"}, {Login: "foo"}},
145 Body: "body",
146 CommentsCount: 1,
147 Labels: []Label{{Name: "label1"}, {Name: "label2"}},
148 IsLocked: true,
149 RepositoryURL: "https://github.com/owner/repo",
150 Title: "title",
151 UpdatedAt: updatedAt,
152 },
153 output: `{"assignees":[{"id":"123","is_bot":false,"login":"test","type":"","url":""},{"id":"","is_bot":true,"login":"app/foo","type":"","url":""}],"body":"body","commentsCount":1,"isLocked":true,"labels":[{"color":"","description":"","id":"","name":"label1"},{"color":"","description":"","id":"","name":"label2"}],"repository":{"name":"repo","nameWithOwner":"owner/repo"},"title":"title","updatedAt":"2021-02-28T12:30:00Z"}`,
154 },
155 {
156 name: "state when issue",
157 fields: []string{"isPullRequest", "state"},
158 issue: Issue{
159 StateInternal: "closed",
160 },
161 output: `{"isPullRequest":false,"state":"closed"}`,
162 },
163 {
164 name: "state when pull request",
165 fields: []string{"isPullRequest", "state"},
166 issue: Issue{
167 PullRequest: PullRequest{
168 MergedAt: time.Now(),
169 URL: "a-url",
170 },
171 StateInternal: "closed",
172 },
173 output: `{"isPullRequest":true,"state":"merged"}`,
174 },
175 {
176 name: "isDraft when pull request",
177 fields: []string{"isDraft", "state"},
178 issue: Issue{
179 PullRequest: PullRequest{
180 URL: "a-url",
181 },
182 StateInternal: "open",
183 IsDraft: &trueValue,
184 },
185 output: `{"isDraft":true,"state":"open"}`,
186 },
187 }
188 for _, tt := range tests {

Callers

nothing calls this directly

Calls 4

EqualMethod · 0.80
RunMethod · 0.65
ExportDataMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected