mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
bbe7029d0a
* Request trace by id using v2, fallback for v1 when 404 * Show partial traces badge in Trace View * update go work sum * Fix tests * some linting * Fix tests and try to ignore linter * Move no lint * nolint:bodyclose * merge main * Fix null tags in array * Fix test * Update go.sum * Update go.sum
45 lines
1.8 KiB
Go
45 lines
1.8 KiB
Go
package tempo
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestTempo(t *testing.T) {
|
|
t.Run("createRequest v1 without time range - success", func(t *testing.T) {
|
|
service := &Service{logger: backend.NewLoggerWith("logger", "tempo-test")}
|
|
req, err := service.createRequest(context.Background(), &Datasource{}, TraceRequestApiVersionV1, "traceID", 0, 0)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, 1, len(req.Header))
|
|
assert.Equal(t, "/api/traces/traceID", req.URL.String())
|
|
})
|
|
|
|
t.Run("createRequest v1 with time range - success", func(t *testing.T) {
|
|
service := &Service{logger: backend.NewLoggerWith("logger", "tempo-test")}
|
|
req, err := service.createRequest(context.Background(), &Datasource{}, TraceRequestApiVersionV1, "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())
|
|
})
|
|
|
|
t.Run("createRequest v2 without time range - success", func(t *testing.T) {
|
|
service := &Service{logger: backend.NewLoggerWith("logger", "tempo-test")}
|
|
req, err := service.createRequest(context.Background(), &Datasource{}, TraceRequestApiVersionV2, "traceID", 0, 0)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, 1, len(req.Header))
|
|
assert.Equal(t, "/api/v2/traces/traceID", req.URL.String())
|
|
})
|
|
|
|
t.Run("createRequest v2 with time range - success", func(t *testing.T) {
|
|
service := &Service{logger: backend.NewLoggerWith("logger", "tempo-test")}
|
|
req, err := service.createRequest(context.Background(), &Datasource{}, TraceRequestApiVersionV2, "traceID", 1, 2)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, 1, len(req.Header))
|
|
assert.Equal(t, "/api/v2/traces/traceID?start=1&end=2", req.URL.String())
|
|
})
|
|
}
|