19
19
20
20
func testTarget (t testing.TB , handler http.HandlerFunc ) * Target {
21
21
t .Helper ()
22
+
22
23
_ , targetURL := testBackendWithHandler (t , handler )
23
24
24
25
target , err := NewTarget (targetURL , defaultTargetOptions )
@@ -28,6 +29,7 @@ func testTarget(t testing.TB, handler http.HandlerFunc) *Target {
28
29
29
30
func testTargetWithOptions (t testing.TB , targetOptions TargetOptions , handler http.HandlerFunc ) * Target {
30
31
t .Helper ()
32
+
31
33
_ , targetURL := testBackendWithHandler (t , handler )
32
34
33
35
target , err := NewTarget (targetURL , targetOptions )
@@ -37,6 +39,7 @@ func testTargetWithOptions(t testing.TB, targetOptions TargetOptions, handler ht
37
39
38
40
func testBackend (t testing.TB , body string , statusCode int ) (* httptest.Server , string ) {
39
41
t .Helper ()
42
+
40
43
return testBackendWithHandler (t , func (w http.ResponseWriter , r * http.Request ) {
41
44
w .WriteHeader (statusCode )
42
45
w .Write ([]byte (body ))
@@ -45,6 +48,7 @@ func testBackend(t testing.TB, body string, statusCode int) (*httptest.Server, s
45
48
46
49
func testBackendWithHandler (t testing.TB , handler http.HandlerFunc ) (* httptest.Server , string ) {
47
50
t .Helper ()
51
+
48
52
server := httptest .NewServer (handler )
49
53
t .Cleanup (server .Close )
50
54
@@ -56,6 +60,7 @@ func testBackendWithHandler(t testing.TB, handler http.HandlerFunc) (*httptest.S
56
60
57
61
func testServer (t testing.TB ) (* Server , string ) {
58
62
t .Helper ()
63
+
59
64
config := & Config {
60
65
Bind : "127.0.0.1" ,
61
66
HttpPort : 0 ,
0 commit comments