1
1
/****************************************************************************
2
- * Copyright 2019, 2021 Optimizely, Inc. and contributors *
2
+ * Copyright 2019,2021-2022 Optimizely, Inc. and contributors *
3
3
* *
4
4
* Licensed under the Apache License, Version 2.0 (the "License"); *
5
5
* you may not use this file except in compliance with the License. *
@@ -19,17 +19,36 @@ package utils
19
19
import (
20
20
"errors"
21
21
"fmt"
22
- "github.com/optimizely/go-sdk/pkg/logging"
23
22
"log"
24
23
"net/http"
25
24
"net/http/httptest"
26
25
"net/url"
27
26
"testing"
28
27
"time"
29
28
29
+ "github.com/optimizely/go-sdk/pkg/logging"
30
+
30
31
"github.com/stretchr/testify/assert"
31
32
)
32
33
34
+ func TestClientFunction (t * testing.T ) {
35
+ requester := & HTTPRequester {}
36
+ fn := Client (http.Client {Timeout : 125 })
37
+ fn (requester )
38
+ assert .Equal (t , time .Duration (125 ), requester .client .Timeout )
39
+ }
40
+
41
+ func TestNewHTTPRequesterWithClient (t * testing.T ) {
42
+ fn := Client (http.Client {Timeout : 125 })
43
+ requester := NewHTTPRequester (logging .GetLogger ("" , "" ), fn )
44
+ assert .Equal (t , time .Duration (125 ), requester .client .Timeout )
45
+ }
46
+
47
+ func TestNewHTTPRequesterWithoutClient (t * testing.T ) {
48
+ requester := NewHTTPRequester (logging .GetLogger ("" , "" ))
49
+ assert .Equal (t , defaultTTL , requester .client .Timeout )
50
+ }
51
+
33
52
func TestHeaders (t * testing.T ) {
34
53
requester := & HTTPRequester {}
35
54
fn := Headers (Header {"one" , "1" })
0 commit comments