Skip to content

Commit

Permalink
Added test for StackSet.Legend
Browse files Browse the repository at this point in the history
  • Loading branch information
ghemawat committed Jul 22, 2024
1 parent 96b4f1c commit a99a299
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/report/stacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package report
import (
"fmt"
"reflect"
"strings"
"testing"

"github.com/google/pprof/profile"
Expand Down Expand Up @@ -164,6 +165,22 @@ func TestStackSources(t *testing.T) {
}
}

func TestLegend(t *testing.T) {
// See report_test.go for the functions available to use in tests.
main, foo, bar, tee := testL[0], testL[1], testL[2], testL[3]
stacks := makeTestStacks(
testSample(100, bar, foo, main),
testSample(200, tee, foo, main),
)
got := strings.Join(stacks.Legend(), "\n")
expectStrings := []string{"Type: samples", "Showing nodes", "100% of 300 total"}
for _, expect := range expectStrings {
if !strings.Contains(got, expect) {
t.Errorf("missing expected string %q in legend %q", expect, got)
}
}
}

func findSource(stacks StackSet, name string) StackSource {
for _, src := range stacks.Sources {
if src.FullName == name {
Expand Down

0 comments on commit a99a299

Please sign in to comment.