github.com/grafana/pyroscope@v1.18.0/pkg/model/time_test.go (about)

     1  package model
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	typesv1 "github.com/grafana/pyroscope/api/gen/proto/go/types/v1"
     9  )
    10  
    11  func Test_SetTimeRange(t *testing.T) {
    12  	t.Run("Type has time range fields", func(t *testing.T) {
    13  		r := new(typesv1.LabelNamesRequest)
    14  		assert.True(t, SetTimeRange(r, 1, 2))
    15  		assert.Equal(t, int64(1), r.Start)
    16  		assert.Equal(t, int64(2), r.End)
    17  	})
    18  	t.Run("Type has no time range fields", func(t *testing.T) {
    19  		r := new(struct{})
    20  		assert.False(t, SetTimeRange(r, 1, 2))
    21  	})
    22  }