debian-mirror-gitlab/workhorse/internal/headers/headers_test.go
2021-02-22 17:27:13 +05:30

24 lines
701 B
Go

package headers
import (
"net/http/httptest"
"testing"
"github.com/stretchr/testify/require"
)
func TestIsDetectContentTypeHeaderPresent(t *testing.T) {
rw := httptest.NewRecorder()
rw.Header().Del(GitlabWorkhorseDetectContentTypeHeader)
require.Equal(t, false, IsDetectContentTypeHeaderPresent(rw))
rw.Header().Set(GitlabWorkhorseDetectContentTypeHeader, "true")
require.Equal(t, true, IsDetectContentTypeHeaderPresent(rw))
rw.Header().Set(GitlabWorkhorseDetectContentTypeHeader, "false")
require.Equal(t, false, IsDetectContentTypeHeaderPresent(rw))
rw.Header().Set(GitlabWorkhorseDetectContentTypeHeader, "foobar")
require.Equal(t, false, IsDetectContentTypeHeaderPresent(rw))
}