(t *testing.T)
| 446 | } |
| 447 | |
| 448 | func TestDocURLMerge(t *testing.T) { |
| 449 | const url1 = "http://example.com/url1" |
| 450 | const url2 = "http://example.com/url2" |
| 451 | type testCase struct { |
| 452 | name string |
| 453 | profiles []*Profile |
| 454 | want string |
| 455 | } |
| 456 | profile := func(url string) *Profile { |
| 457 | return &Profile{ |
| 458 | PeriodType: &ValueType{Type: "cpu", Unit: "seconds"}, |
| 459 | DocURL: url, |
| 460 | } |
| 461 | } |
| 462 | for _, test := range []testCase{ |
| 463 | { |
| 464 | name: "nolinks", |
| 465 | profiles: []*Profile{ |
| 466 | profile(""), |
| 467 | profile(""), |
| 468 | }, |
| 469 | want: "", |
| 470 | }, |
| 471 | { |
| 472 | name: "single", |
| 473 | profiles: []*Profile{ |
| 474 | profile(url1), |
| 475 | }, |
| 476 | want: url1, |
| 477 | }, |
| 478 | { |
| 479 | name: "mix", |
| 480 | profiles: []*Profile{ |
| 481 | profile(""), |
| 482 | profile(url1), |
| 483 | }, |
| 484 | want: url1, |
| 485 | }, |
| 486 | { |
| 487 | name: "different", |
| 488 | profiles: []*Profile{ |
| 489 | profile(url1), |
| 490 | profile(url2), |
| 491 | }, |
| 492 | want: url1, |
| 493 | }, |
| 494 | } { |
| 495 | t.Run(test.name, func(t *testing.T) { |
| 496 | merged, err := combineHeaders(test.profiles) |
| 497 | if err != nil { |
| 498 | t.Fatal(err) |
| 499 | } |
| 500 | got := merged.DocURL |
| 501 | if !reflect.DeepEqual(test.want, got) { |
| 502 | t.Errorf("unexpected links; want: %#v, got: %#v", test.want, got) |
| 503 | } |
| 504 | }) |
| 505 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…