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

Function TestIssueView_json_BlockedByBlocking

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

Source from the content-addressed store, hash-verified

1005}
1006
1007func TestIssueView_json_BlockedByBlocking(t *testing.T) {
1008 httpReg := &httpmock.Registry{}
1009 defer httpReg.Verify(t)
1010
1011 httpReg.Register(
1012 httpmock.GraphQL(`query IssueByNumber\b`),
1013 httpmock.StringResponse(issueResponseAllIssues2Fields()),
1014 )
1015
1016 output, err := runCommand(httpReg, false, `123 --json blockedBy,blocking`)
1017 require.NoError(t, err)
1018
1019 var data map[string]any
1020 require.NoError(t, json.Unmarshal(output.OutBuf.Bytes(), &data))
1021
1022 // Blocked by
1023 blockedByObj, ok := data["blockedBy"].(map[string]any)
1024 require.True(t, ok, "blockedBy should be an object")
1025 assert.Equal(t, float64(1), blockedByObj["totalCount"])
1026
1027 blockedBy, ok := blockedByObj["nodes"].([]any)
1028 require.True(t, ok, "blockedBy.nodes should be an array")
1029 require.Len(t, blockedBy, 1)
1030
1031 blocked0 := blockedBy[0].(map[string]any)
1032 assert.Equal(t, float64(200), blocked0["number"])
1033 assert.Equal(t, "API rate limiting", blocked0["title"])
1034 assert.Equal(t, "https://github.com/OWNER/REPO/issues/200", blocked0["url"])
1035 assert.Equal(t, "OPEN", blocked0["state"])
1036
1037 // Blocking
1038 blockingObj, ok := data["blocking"].(map[string]any)
1039 require.True(t, ok, "blocking should be an object")
1040 assert.Equal(t, float64(1), blockingObj["totalCount"])
1041
1042 blocking, ok := blockingObj["nodes"].([]any)
1043 require.True(t, ok, "blocking.nodes should be an array")
1044 require.Len(t, blocking, 1)
1045
1046 blocking0 := blocking[0].(map[string]any)
1047 assert.Equal(t, float64(300), blocking0["number"])
1048 assert.Equal(t, "Release v2.0", blocking0["title"])
1049 assert.Equal(t, "https://github.com/OWNER/REPO/issues/300", blocking0["url"])
1050 assert.Equal(t, "OPEN", blocking0["state"])
1051}

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