github.com/grafana/pyroscope@v1.18.0/pkg/querybackend/queryplan/query_plan_test.go (about) 1 package queryplan 2 3 import ( 4 "bytes" 5 "os" 6 "testing" 7 8 "github.com/stretchr/testify/assert" 9 "github.com/stretchr/testify/require" 10 11 metastorev1 "github.com/grafana/pyroscope/api/gen/proto/go/metastore/v1" 12 ) 13 14 func Test_Plan(t *testing.T) { 15 blocks := []*metastorev1.BlockMeta{ 16 {Id: "1"}, {Id: "2"}, 17 {Id: "3"}, {Id: "4"}, 18 {Id: "5"}, {Id: "6"}, 19 {Id: "7"}, {Id: "8"}, 20 {Id: "9"}, {Id: "10"}, 21 {Id: "11"}, {Id: "12"}, 22 {Id: "13"}, {Id: "14"}, 23 {Id: "15"}, {Id: "16"}, 24 {Id: "17"}, {Id: "18"}, 25 {Id: "19"}, {Id: "20"}, 26 {Id: "21"}, {Id: "22"}, 27 {Id: "23"}, {Id: "24"}, 28 {Id: "25"}, 29 } 30 31 p := Build(blocks, 2, 3) 32 var buf bytes.Buffer 33 printPlan(&buf, "", p.Root, true) 34 // Ensure that the plan has not been modified 35 // during traversal performed by printPlan. 36 assert.Equal(t, Build(blocks, 2, 3), p) 37 38 expected, err := os.ReadFile("testdata/plan.txt") 39 require.NoError(t, err) 40 assert.Equal(t, string(expected), buf.String()) 41 }