photoprism/internal/httpclient/httpclient_test.go
2021-09-09 11:33:27 +02:00

29 lines
682 B
Go

package httpclient
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestClient(t *testing.T) {
t.Run("default client", func(t *testing.T) {
client := Client(false)
assert.IsType(t, http.DefaultClient, client)
assert.IsType(t, nil, client.Transport)
})
t.Run("logging proxy client", func(t *testing.T) {
client := Client(true)
assert.IsType(t, LoggingRoundTripper{}, client.Transport)
})
t.Run("RoundTripper working", func(t *testing.T) {
req, err := http.NewRequest("GET", "https://photoprism.app", nil)
assert.Nil(t, err)
rt := LoggingRoundTripper{http.DefaultTransport}
_, err = rt.RoundTrip(req)
assert.Nil(t, err)
})
}