2021-03-11 01:18:24 -06:00
|
|
|
package tempo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
2021-03-11 01:18:24 -06:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestTempo(t *testing.T) {
|
2022-10-21 09:38:10 -05:00
|
|
|
t.Run("createRequest without time range - success", func(t *testing.T) {
|
2021-08-25 08:11:22 -05:00
|
|
|
service := &Service{tlog: log.New("tempo-test")}
|
2022-10-21 09:38:10 -05:00
|
|
|
req, err := service.createRequest(context.Background(), &datasourceInfo{}, "traceID", 0, 0)
|
2021-03-11 01:18:24 -06:00
|
|
|
require.NoError(t, err)
|
2021-08-05 04:14:17 -05:00
|
|
|
assert.Equal(t, 1, len(req.Header))
|
2021-03-11 01:18:24 -06:00
|
|
|
})
|
2022-10-21 09:38:10 -05:00
|
|
|
|
|
|
|
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())
|
|
|
|
})
|
2021-03-11 01:18:24 -06:00
|
|
|
}
|