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

Function TestGraphQLError

api/client_test.go:47–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

45}
46
47func TestGraphQLError(t *testing.T) {
48 reg := &httpmock.Registry{}
49 client := newTestClient(reg)
50
51 response := struct{}{}
52
53 reg.Register(
54 httpmock.GraphQL(""),
55 httpmock.StringResponse(`
56 { "errors": [
57 {
58 "type": "NOT_FOUND",
59 "message": "OH NO",
60 "path": ["repository", "issue"]
61 },
62 {
63 "type": "ACTUALLY_ITS_FINE",
64 "message": "this is fine",
65 "path": ["repository", "issues", 0, "comments"]
66 }
67 ]
68 }
69 `),
70 )
71
72 err := client.GraphQL("github.com", "", nil, &response)
73 if err == nil || err.Error() != "GraphQL: OH NO (repository.issue), this is fine (repository.issues.0.comments)" {
74 t.Fatalf("got %q", err.Error())
75 }
76}
77
78func TestRESTGetDelete(t *testing.T) {
79 http := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 6

RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
newTestClientFunction · 0.85
GraphQLMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected