MCPcopy Create free account
hub / github.com/prometheus/common / TestProxyConfiguration

Function TestProxyConfiguration

config/http_config_test.go:513–555  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

511}
512
513func 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
557func TestNewClientFromInvalidConfig(t *testing.T) {
558 newClientInvalidConfig := []struct {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected