(t *testing.T)
| 125 | } |
| 126 | |
| 127 | func TestCustomHTTPQuery(t *testing.T) { |
| 128 | b, err := os.ReadFile("custom_query_test.yaml") |
| 129 | require.NoError(t, err, "Unable to read test file") |
| 130 | |
| 131 | var tests []HTTPRewritingCase |
| 132 | err = yaml.Unmarshal(b, &tests) |
| 133 | require.NoError(t, err, "Unable to unmarshal tests to yaml.") |
| 134 | |
| 135 | gqlSchema := test.LoadSchemaFromFile(t, "schema.graphql") |
| 136 | |
| 137 | for _, tcase := range tests { |
| 138 | t.Run(tcase.Name, func(t *testing.T) { |
| 139 | var vars map[string]interface{} |
| 140 | if tcase.Variables != "" { |
| 141 | require.NoError(t, json.Unmarshal([]byte(tcase.Variables), &vars)) |
| 142 | } |
| 143 | |
| 144 | op, err := gqlSchema.Operation( |
| 145 | &schema.Request{ |
| 146 | Query: tcase.GQLQuery, |
| 147 | Variables: vars, |
| 148 | Header: map[string][]string{ |
| 149 | "bogus": {"header"}, |
| 150 | "X-App-Token": {"val"}, |
| 151 | "Auth0-Token": {"tok"}, |
| 152 | }, |
| 153 | }) |
| 154 | require.NoError(t, err) |
| 155 | gqlQuery := test.GetQuery(t, op) |
| 156 | |
| 157 | client := newClient(t, tcase) |
| 158 | resolver := NewHTTPQueryResolver(client) |
| 159 | resolved := resolver.Resolve(context.Background(), gqlQuery) |
| 160 | |
| 161 | testutil.CompareJSON(t, tcase.ResolvedResponse, string(resolved.Data)) |
| 162 | }) |
| 163 | } |
| 164 | } |
nothing calls this directly
no test coverage detected