github.com/blend/go-sdk@v1.20220411.3/r2/opt_client_test.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package r2 9 10 import ( 11 "net/http" 12 "testing" 13 "time" 14 15 "github.com/blend/go-sdk/assert" 16 ) 17 18 func TestOptClient(t *testing.T) { 19 it := assert.New(t) 20 21 client := &http.Client{ 22 Timeout: time.Second, 23 } 24 req := New("https://localhost:8080", OptClient(client)) 25 it.Nil(req.Err) 26 it.NotNil(req.Client) 27 it.Equal(time.Second, req.Client.Timeout) 28 29 xport := &http.Transport{} 30 err := OptTransport(xport)(req) 31 it.Nil(err) 32 it.Equal(time.Second, req.Client.Timeout) 33 it.NotNil(req.Client.Transport) 34 }