(t *testing.T)
| 993 | } |
| 994 | |
| 995 | func TestIssueView_json_BlockedByBlocking(t *testing.T) { |
| 996 | httpReg := &httpmock.Registry{} |
| 997 | defer httpReg.Verify(t) |
| 998 | |
| 999 | httpReg.Register( |
| 1000 | httpmock.GraphQL(`query IssueByNumber\b`), |
| 1001 | httpmock.StringResponse(issueResponseAllIssues2Fields()), |
| 1002 | ) |
| 1003 | |
| 1004 | output, err := runCommand(httpReg, false, `123 --json blockedBy,blocking`) |
| 1005 | require.NoError(t, err) |
| 1006 | |
| 1007 | var data map[string]interface{} |
| 1008 | require.NoError(t, json.Unmarshal(output.OutBuf.Bytes(), &data)) |
| 1009 | |
| 1010 | // Blocked by |
| 1011 | blockedByObj, ok := data["blockedBy"].(map[string]interface{}) |
| 1012 | require.True(t, ok, "blockedBy should be an object") |
| 1013 | assert.Equal(t, float64(1), blockedByObj["totalCount"]) |
| 1014 | |
| 1015 | blockedBy, ok := blockedByObj["nodes"].([]interface{}) |
| 1016 | require.True(t, ok, "blockedBy.nodes should be an array") |
| 1017 | require.Len(t, blockedBy, 1) |
| 1018 | |
| 1019 | blocked0 := blockedBy[0].(map[string]interface{}) |
| 1020 | assert.Equal(t, float64(200), blocked0["number"]) |
| 1021 | assert.Equal(t, "API rate limiting", blocked0["title"]) |
| 1022 | assert.Equal(t, "https://github.com/OWNER/REPO/issues/200", blocked0["url"]) |
| 1023 | assert.Equal(t, "OPEN", blocked0["state"]) |
| 1024 | |
| 1025 | // Blocking |
| 1026 | blockingObj, ok := data["blocking"].(map[string]interface{}) |
| 1027 | require.True(t, ok, "blocking should be an object") |
| 1028 | assert.Equal(t, float64(1), blockingObj["totalCount"]) |
| 1029 | |
| 1030 | blocking, ok := blockingObj["nodes"].([]interface{}) |
| 1031 | require.True(t, ok, "blocking.nodes should be an array") |
| 1032 | require.Len(t, blocking, 1) |
| 1033 | |
| 1034 | blocking0 := blocking[0].(map[string]interface{}) |
| 1035 | assert.Equal(t, float64(300), blocking0["number"]) |
| 1036 | assert.Equal(t, "Release v2.0", blocking0["title"]) |
| 1037 | assert.Equal(t, "https://github.com/OWNER/REPO/issues/300", blocking0["url"]) |
| 1038 | assert.Equal(t, "OPEN", blocking0["state"]) |
| 1039 | } |
nothing calls this directly
no test coverage detected