(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestRequestName(t *testing.T) { |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | method string |
| 15 | host string |
| 16 | path string |
| 17 | query string |
| 18 | variables string |
| 19 | selected string |
| 20 | rawBody string |
| 21 | wantGraphQL bool |
| 22 | wantName string |
| 23 | wantKind string |
| 24 | wantOp string |
| 25 | wantVars string |
| 26 | }{ |
| 27 | { |
| 28 | name: "operationName selects a later mutation", |
| 29 | method: "POST", |
| 30 | host: apiHost, |
| 31 | path: "/graphql", |
| 32 | query: `query First { viewer { login } } mutation Second { closeIssue(input:{issueId:"1"}) { issue { title } } }`, |
| 33 | selected: "Second", |
| 34 | wantName: "graphql Second", |
| 35 | wantKind: "mutation", |
| 36 | wantOp: "Second", |
| 37 | }, |
| 38 | { |
| 39 | name: "operationName can select a later query", |
| 40 | method: "POST", |
| 41 | host: apiHost, |
| 42 | path: "/graphql", |
| 43 | query: `query First { viewer { login } } query Second { viewer { name } }`, |
| 44 | selected: "Second", |
| 45 | wantName: "graphql Second", |
| 46 | wantKind: "query", |
| 47 | wantOp: "Second", |
| 48 | }, |
| 49 | { |
| 50 | name: "missing operationName does not select the first of several", |
| 51 | method: "POST", |
| 52 | host: apiHost, |
| 53 | path: "/graphql", |
| 54 | query: `query First { viewer { login } } query Second { viewer { name } }`, |
| 55 | wantName: "graphql <anonymous>", |
| 56 | wantGraphQL: true, |
| 57 | }, |
| 58 | { |
| 59 | name: "unknown operationName does not select another operation", |
| 60 | method: "POST", |
| 61 | host: apiHost, |
| 62 | path: "/graphql", |
| 63 | query: `query First { viewer { login } }`, |
| 64 | selected: "Missing", |
| 65 | wantName: "graphql Missing", |
| 66 | wantOp: "Missing", |
| 67 | wantGraphQL: true, |
| 68 | }, |
nothing calls this directly
no test coverage detected