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

Function TestIssueView_json_ParentSubIssues

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

Source from the content-addressed store, hash-verified

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