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

Function TestGraphQLError

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

Source from the content-addressed store, hash-verified

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