Skip to content

Commit ecfc1dd

Browse files
Minor test changes
1 parent bc8525d commit ecfc1dd

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

internal/server/health_check_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestHealthCheck(t *testing.T) {
2323
serverURL.Path = path
2424

2525
hc := NewHealthCheck(consumer, serverURL, shortTimeout, shortTimeout)
26-
defer hc.Close()
26+
t.Cleanup(hc.Close)
2727

2828
for _, exp := range expected {
2929
result := <-consumer
@@ -76,9 +76,9 @@ func testHealthCheckTarget(t testing.TB) *url.URL {
7676
}
7777
case "/slow":
7878
time.Sleep(longTimeout)
79-
default:
80-
w.WriteHeader(http.StatusOK)
8179
}
80+
81+
w.WriteHeader(http.StatusOK)
8282
}))
8383
t.Cleanup(server.Close)
8484

internal/server/testing.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var (
1919

2020
func testTarget(t testing.TB, handler http.HandlerFunc) *Target {
2121
t.Helper()
22+
2223
_, targetURL := testBackendWithHandler(t, handler)
2324

2425
target, err := NewTarget(targetURL, defaultTargetOptions)
@@ -28,6 +29,7 @@ func testTarget(t testing.TB, handler http.HandlerFunc) *Target {
2829

2930
func testTargetWithOptions(t testing.TB, targetOptions TargetOptions, handler http.HandlerFunc) *Target {
3031
t.Helper()
32+
3133
_, targetURL := testBackendWithHandler(t, handler)
3234

3335
target, err := NewTarget(targetURL, targetOptions)
@@ -37,6 +39,7 @@ func testTargetWithOptions(t testing.TB, targetOptions TargetOptions, handler ht
3739

3840
func testBackend(t testing.TB, body string, statusCode int) (*httptest.Server, string) {
3941
t.Helper()
42+
4043
return testBackendWithHandler(t, func(w http.ResponseWriter, r *http.Request) {
4144
w.WriteHeader(statusCode)
4245
w.Write([]byte(body))
@@ -45,6 +48,7 @@ func testBackend(t testing.TB, body string, statusCode int) (*httptest.Server, s
4548

4649
func testBackendWithHandler(t testing.TB, handler http.HandlerFunc) (*httptest.Server, string) {
4750
t.Helper()
51+
4852
server := httptest.NewServer(handler)
4953
t.Cleanup(server.Close)
5054

@@ -56,6 +60,7 @@ func testBackendWithHandler(t testing.TB, handler http.HandlerFunc) (*httptest.S
5660

5761
func testServer(t testing.TB) (*Server, string) {
5862
t.Helper()
63+
5964
config := &Config{
6065
Bind: "127.0.0.1",
6166
HttpPort: 0,

0 commit comments

Comments
 (0)