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

Function TestIssueView_json_ParentSubIssues

pkg/cmd/issue/view/view_test.go:957–1005  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

955}
956
957func TestIssueView_json_ParentSubIssues(t *testing.T) {
958 httpReg := &httpmock.Registry{}
959 defer httpReg.Verify(t)
960
961 httpReg.Register(
962 httpmock.GraphQL(`query IssueByNumber\b`),
963 httpmock.StringResponse(issueResponseAllIssues2Fields()),
964 )
965
966 output, err := runCommand(httpReg, false, `123 --json parent,subIssues,subIssuesSummary`)
967 require.NoError(t, err)
968
969 var data map[string]any
970 require.NoError(t, json.Unmarshal(output.OutBuf.Bytes(), &data))
971
972 // Parent
973 parent, ok := data["parent"].(map[string]any)
974 require.True(t, ok, "parent should be an object")
975 assert.Equal(t, float64(100), parent["number"])
976 assert.Equal(t, "Epic: Authentication overhaul", parent["title"])
977 assert.Equal(t, "https://github.com/OWNER/REPO/issues/100", parent["url"])
978 assert.Equal(t, "OPEN", parent["state"])
979
980 // Sub-issues
981 subIssuesObj, ok := data["subIssues"].(map[string]any)
982 require.True(t, ok, "subIssues should be an object")
983 assert.Equal(t, float64(2), subIssuesObj["totalCount"])
984
985 subIssues, ok := subIssuesObj["nodes"].([]any)
986 require.True(t, ok, "subIssues.nodes should be an array")
987 require.Len(t, subIssues, 2)
988
989 sub0 := subIssues[0].(map[string]any)
990 assert.Equal(t, float64(101), sub0["number"])
991 assert.Equal(t, "Design auth module", sub0["title"])
992 assert.Equal(t, "CLOSED", sub0["state"])
993
994 sub1 := subIssues[1].(map[string]any)
995 assert.Equal(t, float64(102), sub1["number"])
996 assert.Equal(t, "Token refresh logic", sub1["title"])
997 assert.Equal(t, "OPEN", sub1["state"])
998
999 // Sub-issues summary
1000 summary, ok := data["subIssuesSummary"].(map[string]any)
1001 require.True(t, ok, "subIssuesSummary should be an object")
1002 assert.Equal(t, float64(2), summary["total"])
1003 assert.Equal(t, float64(1), summary["completed"])
1004 assert.Equal(t, float64(50), summary["percentCompleted"])
1005}
1006
1007func TestIssueView_json_BlockedByBlocking(t *testing.T) {
1008 httpReg := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 8

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
EqualMethod · 0.80
runCommandFunction · 0.70
LenMethod · 0.65

Tested by

no test coverage detected