mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 04:04:00 -06:00
27 lines
598 B
Go
27 lines
598 B
Go
package request
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestAcceptHeader(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
t.Run("should not set ctx for empty header", func(t *testing.T) {
|
|
out := WithAcceptHeader(ctx, "")
|
|
acceptHeader, ok := AcceptHeaderFrom(out)
|
|
require.False(t, ok)
|
|
require.Empty(t, acceptHeader)
|
|
})
|
|
|
|
t.Run("should add header to ctx", func(t *testing.T) {
|
|
out := WithAcceptHeader(ctx, "application/json")
|
|
acceptHeader, ok := AcceptHeaderFrom(out)
|
|
require.True(t, ok)
|
|
require.Equal(t, "application/json", acceptHeader)
|
|
})
|
|
}
|