mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Replace histogram collector and grpc injectors * Extract request timing utility * Also vendor test file * Suppress erroneous linter warn
30 lines
727 B
Go
30 lines
727 B
Go
package historian
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestTimedClient_operationName(t *testing.T) {
|
|
r, err := http.NewRequest("GET", "https://weave.test", nil)
|
|
assert.NoError(t, err)
|
|
|
|
r = r.WithContext(context.WithValue(context.Background(), OperationNameContextKey, "opp"))
|
|
c := NewTimedClient(http.DefaultClient, nil)
|
|
|
|
assert.Equal(t, "opp", c.operationName(r))
|
|
}
|
|
|
|
func TestTimedClient_operationName_Default(t *testing.T) {
|
|
r, err := http.NewRequest("GET", "https://weave.test/you/know/me", nil)
|
|
assert.NoError(t, err)
|
|
|
|
r = r.WithContext(context.Background())
|
|
c := NewTimedClient(http.DefaultClient, nil)
|
|
|
|
assert.Equal(t, "/you/know/me", c.operationName(r))
|
|
}
|