grafana/pkg/tsdb/tempo/tempo_test.go
bikashmishra100 98053cfde8
Tempo: Add start time and end time parameters while querying traces (#48068)
* Add start time and end time parameters while querying tempo traces

* Added configurable time shift to query by trace id

* Test that the URL is formatted correctly

* Added test to check for time shift

* Improved label and tooltip of new time shift settings

Co-authored-by: André Pereira <adrapereira@gmail.com>
2022-10-21 15:38:10 +01:00

28 lines
849 B
Go

package tempo
import (
"context"
"testing"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestTempo(t *testing.T) {
t.Run("createRequest without time range - success", func(t *testing.T) {
service := &Service{tlog: log.New("tempo-test")}
req, err := service.createRequest(context.Background(), &datasourceInfo{}, "traceID", 0, 0)
require.NoError(t, err)
assert.Equal(t, 1, len(req.Header))
})
t.Run("createRequest with time range - success", func(t *testing.T) {
service := &Service{tlog: log.New("tempo-test")}
req, err := service.createRequest(context.Background(), &datasourceInfo{}, "traceID", 1, 2)
require.NoError(t, err)
assert.Equal(t, 1, len(req.Header))
assert.Equal(t, "/api/traces/traceID?start=1&end=2", req.URL.String())
})
}