MCPcopy Index your code
hub / github.com/cli/cli / TestJSONProjectDetailedItems

Function TestJSONProjectDetailedItems

pkg/cmd/project/shared/queries/export_data_test.go:219–276  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

217}
218
219func TestJSONProjectDetailedItems(t *testing.T) {
220 p := &Project{}
221 p.Items.TotalCount = 5
222 p.Items.Nodes = []ProjectItem{
223 {
224 Id: "issueId",
225 Content: ProjectItemContent{
226 TypeName: "Issue",
227 Issue: Issue{
228 Title: "Issue title",
229 Body: "a body",
230 Number: 1,
231 URL: "issue-url",
232 Repository: struct {
233 NameWithOwner string
234 }{
235 NameWithOwner: "cli/go-gh",
236 },
237 },
238 },
239 },
240 {
241 Id: "pullRequestId",
242 Content: ProjectItemContent{
243 TypeName: "PullRequest",
244 PullRequest: PullRequest{
245 Title: "Pull Request title",
246 Body: "a body",
247 Number: 2,
248 URL: "pr-url",
249 Repository: struct {
250 NameWithOwner string
251 }{
252 NameWithOwner: "cli/go-gh",
253 },
254 },
255 },
256 },
257 {
258 Id: "draftIssueId",
259 Content: ProjectItemContent{
260 TypeName: "DraftIssue",
261 DraftIssue: DraftIssue{
262 ID: "draftIssueId",
263 Title: "Pull Request title",
264 Body: "a body",
265 },
266 },
267 },
268 }
269
270 out, err := json.Marshal(p.DetailedItems())
271 assert.NoError(t, err)
272 assert.JSONEq(
273 t,
274 `{"items":[{"content":{"type":"Issue","body":"a body","title":"Issue title","number":1,"repository":"cli/go-gh","url":"issue-url"},"id":"issueId"},{"content":{"type":"PullRequest","body":"a body","title":"Pull Request title","number":2,"repository":"cli/go-gh","url":"pr-url"},"id":"pullRequestId"},{"content":{"type":"DraftIssue","body":"a body","title":"Pull Request title","id":"draftIssueId"},"id":"draftIssueId"}],"totalCount":5}`,
275 string(out))
276}

Callers

nothing calls this directly

Calls 1

DetailedItemsMethod · 0.95

Tested by

no test coverage detected