Skip to content

Commit

Permalink
Fix linting and errcheck in crawler test
Browse files Browse the repository at this point in the history
  • Loading branch information
theseanything committed Oct 9, 2023
1 parent 1bfb32a commit 35e655d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/crawler/crawler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func isRedirect(status int) bool {
return status >= 300 && status < 400
}

func newTestServer() *httptest.Server {
func newTestServer(t *testing.T) *httptest.Server {
mux := http.NewServeMux()

for path, response := range routes {
Expand All @@ -138,7 +138,10 @@ func newTestServer() *httptest.Server {
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", response.contentType)
w.WriteHeader(response.status)
w.Write(response.body)
_, err := w.Write(response.body)
if err != nil {
t.Error("Test server unable to write response")
}
})
}
}
Expand Down Expand Up @@ -169,7 +172,7 @@ func TestNewCrawler(t *testing.T) {
}

func TestRun(t *testing.T) {
ts := newTestServer()
ts := newTestServer(t)
defer ts.Close()

tests := []struct {
Expand Down

0 comments on commit 35e655d

Please sign in to comment.