| 552 | } |
| 553 | |
| 554 | func TestDocURL(t *testing.T) { |
| 555 | type testCase struct { |
| 556 | input string |
| 557 | want string |
| 558 | } |
| 559 | for name, c := range map[string]testCase{ |
| 560 | "empty": {"", ""}, |
| 561 | "http": {"http://example.com/pprof-help", "http://example.com/pprof-help"}, |
| 562 | "https": {"https://example.com/pprof-help", "https://example.com/pprof-help"}, |
| 563 | "relative": {"/foo", ""}, |
| 564 | "nonhttp": {"mailto:nobody@example.com", ""}, |
| 565 | } { |
| 566 | t.Run(name, func(t *testing.T) { |
| 567 | profile := testProfile.Copy() |
| 568 | profile.DocURL = c.input |
| 569 | rpt := New(profile, &Options{ |
| 570 | OutputFormat: Dot, |
| 571 | Symbol: regexp.MustCompile(`.`), |
| 572 | TrimPath: "/some/path", |
| 573 | SampleValue: func(v []int64) int64 { return v[1] }, |
| 574 | SampleUnit: testProfile.SampleType[1].Unit, |
| 575 | }) |
| 576 | if got := rpt.DocURL(); got != c.want { |
| 577 | t.Errorf("bad doc URL %q, expecting %q", got, c.want) |
| 578 | } |
| 579 | }) |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | func TestDocURLInLabels(t *testing.T) { |
| 584 | const url = "http://example.com/pprof-help" |