nolint:gocyclo
(t *testing.T)
| 1238 | |
| 1239 | //nolint:gocyclo |
| 1240 | func TestInstrumentation(t *testing.T) { |
| 1241 | successTp := func(_ *http.Request) (*http.Response, error) { |
| 1242 | h := http.Header{} |
| 1243 | h.Add("X-Elastic-Product", "Elasticsearch") |
| 1244 | h.Add("X-Found-Handling-Cluster", "foo-bar-cluster-id") |
| 1245 | h.Add("X-Found-Handling-Instance", "0123456789") |
| 1246 | return &http.Response{ |
| 1247 | StatusCode: http.StatusOK, |
| 1248 | Header: h, |
| 1249 | Body: io.NopCloser(strings.NewReader(`{}`)), |
| 1250 | }, nil |
| 1251 | } |
| 1252 | |
| 1253 | errorTp := func(_ *http.Request) (*http.Response, error) { |
| 1254 | h := http.Header{} |
| 1255 | h.Add("X-Elastic-Product", "Elasticsearch") |
| 1256 | h.Add("X-Found-Handling-Cluster", "foo-bar-cluster-id") |
| 1257 | h.Add("X-Found-Handling-Instance", "0123456789") |
| 1258 | return &http.Response{ |
| 1259 | StatusCode: http.StatusNotFound, |
| 1260 | Header: h, |
| 1261 | Body: io.NopCloser(strings.NewReader(`{ |
| 1262 | "error": { |
| 1263 | "root_cause": [ |
| 1264 | { |
| 1265 | "type": "index_not_found_exception", |
| 1266 | "reason": "no such index [foo]", |
| 1267 | "resource.type": "index_or_alias", |
| 1268 | "resource.id": "foo", |
| 1269 | "index_uuid": "_na_", |
| 1270 | "index": "foo" |
| 1271 | } |
| 1272 | ], |
| 1273 | "type": "index_not_found_exception", |
| 1274 | "reason": "no such index [foo]", |
| 1275 | "resource.type": "index_or_alias", |
| 1276 | "resource.id": "foo", |
| 1277 | "index_uuid": "_na_", |
| 1278 | "index": "foo" |
| 1279 | }, |
| 1280 | "status": 404 |
| 1281 | }`)), |
| 1282 | }, nil |
| 1283 | } |
| 1284 | |
| 1285 | reason := "index_not_found_exception" |
| 1286 | |
| 1287 | type args struct { |
| 1288 | roundTripFunc func(request *http.Request) (*http.Response, error) |
| 1289 | instrumentation *FakeInstrumentation |
| 1290 | } |
| 1291 | tests := []struct { |
| 1292 | name string |
| 1293 | args args |
| 1294 | want *FakeInstrumentation |
| 1295 | }{ |
| 1296 | { |
| 1297 | name: "with query", |
nothing calls this directly
no test coverage detected