(t *testing.T)
| 301 | } |
| 302 | |
| 303 | func TestCopyConfig(t *testing.T) { |
| 304 | f := fuzz.New().NilChance(0.0).NumElements(1, 1) |
| 305 | f.Funcs( |
| 306 | func(r *runtime.Codec, f fuzz.Continue) { |
| 307 | codec := &fakeCodec{} |
| 308 | f.Fuzz(codec) |
| 309 | *r = codec |
| 310 | }, |
| 311 | func(r *http.RoundTripper, f fuzz.Continue) { |
| 312 | roundTripper := &fakeRoundTripper{} |
| 313 | f.Fuzz(roundTripper) |
| 314 | *r = roundTripper |
| 315 | }, |
| 316 | func(fn *func(http.RoundTripper) http.RoundTripper, f fuzz.Continue) { |
| 317 | *fn = fakeWrapperFunc |
| 318 | }, |
| 319 | func(fn *transport.WrapperFunc, f fuzz.Continue) { |
| 320 | *fn = fakeWrapperFunc |
| 321 | }, |
| 322 | func(r *runtime.NegotiatedSerializer, f fuzz.Continue) { |
| 323 | serializer := &fakeNegotiatedSerializer{} |
| 324 | f.Fuzz(serializer) |
| 325 | *r = serializer |
| 326 | }, |
| 327 | func(r *flowcontrol.RateLimiter, f fuzz.Continue) { |
| 328 | limiter := &fakeLimiter{} |
| 329 | f.Fuzz(limiter) |
| 330 | *r = limiter |
| 331 | }, |
| 332 | func(r *AuthProviderConfigPersister, f fuzz.Continue) { |
| 333 | *r = fakeAuthProviderConfigPersister{} |
| 334 | }, |
| 335 | func(r *func(ctx context.Context, network, addr string) (net.Conn, error), f fuzz.Continue) { |
| 336 | *r = fakeDialFunc |
| 337 | }, |
| 338 | ) |
| 339 | for i := 0; i < 20; i++ { |
| 340 | original := &Config{} |
| 341 | f.Fuzz(original) |
| 342 | actual := CopyConfig(original) |
| 343 | expected := *original |
| 344 | |
| 345 | // this is the list of known risky fields, add to this list if a new field |
| 346 | // is added to Config, update CopyConfig to preserve the field otherwise. |
| 347 | |
| 348 | // The DeepEqual cannot handle the func comparison, so we just verify if the |
| 349 | // function return the expected object. |
| 350 | if actual.WrapTransport == nil || !reflect.DeepEqual(expected.WrapTransport(nil), &fakeRoundTripper{}) { |
| 351 | t.Fatalf("CopyConfig dropped the WrapTransport field") |
| 352 | } else { |
| 353 | actual.WrapTransport = nil |
| 354 | expected.WrapTransport = nil |
| 355 | } |
| 356 | if actual.Dial != nil { |
| 357 | _, actualError := actual.Dial(context.Background(), "", "") |
| 358 | _, expectedError := expected.Dial(context.Background(), "", "") |
| 359 | if !reflect.DeepEqual(expectedError, actualError) { |
| 360 | t.Fatalf("CopyConfig dropped the Dial field") |
nothing calls this directly
no test coverage detected