(t *testing.T)
| 511 | } |
| 512 | |
| 513 | func TestProxyConfiguration(t *testing.T) { |
| 514 | testcases := map[string]struct { |
| 515 | testFn string |
| 516 | loader func(string) (*HTTPClientConfig, []byte, error) |
| 517 | isValid bool |
| 518 | }{ |
| 519 | "good yaml": { |
| 520 | testFn: "testdata/http.conf.proxy-headers.good.yml", |
| 521 | loader: LoadHTTPConfigFile, |
| 522 | isValid: true, |
| 523 | }, |
| 524 | "bad yaml": { |
| 525 | testFn: "testdata/http.conf.proxy-headers.bad.yml", |
| 526 | loader: LoadHTTPConfigFile, |
| 527 | isValid: false, |
| 528 | }, |
| 529 | "good json": { |
| 530 | testFn: "testdata/http.conf.proxy-headers.good.json", |
| 531 | loader: loadHTTPConfigJSONFile, |
| 532 | isValid: true, |
| 533 | }, |
| 534 | "bad json": { |
| 535 | testFn: "testdata/http.conf.proxy-headers.bad.json", |
| 536 | loader: loadHTTPConfigJSONFile, |
| 537 | isValid: false, |
| 538 | }, |
| 539 | } |
| 540 | |
| 541 | for name, tc := range testcases { |
| 542 | t.Run(name, func(t *testing.T) { |
| 543 | _, _, err := tc.loader(tc.testFn) |
| 544 | if tc.isValid { |
| 545 | if err != nil { |
| 546 | t.Fatalf("Error validating %s: %s", tc.testFn, err) |
| 547 | } |
| 548 | } else { |
| 549 | if err == nil { |
| 550 | t.Fatalf("Expecting error validating %s but got %s", tc.testFn, err) |
| 551 | } |
| 552 | } |
| 553 | }) |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | func TestNewClientFromInvalidConfig(t *testing.T) { |
| 558 | newClientInvalidConfig := []struct { |
nothing calls this directly
no outgoing calls
no test coverage detected