photoprism/internal/httpclient/httpclient_test.go

30 lines
682 B
Go
Raw Normal View History

2021-09-08 17:46:30 +02:00
package httpclient
import (
"net/http"
"testing"
2021-09-09 11:08:45 +02:00
"github.com/stretchr/testify/assert"
2021-09-08 17:46:30 +02:00
)
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)
})
}