From 837a32db565ae11bbfa76b6cecacec4c25c5e118 Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Sat, 16 Apr 2016 10:53:08 +0200 Subject: [PATCH] Use correct method --- api/api.go | 3 +-- api/api_test.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/api/api.go b/api/api.go index b0c139a..70f252e 100644 --- a/api/api.go +++ b/api/api.go @@ -98,7 +98,6 @@ func testPort(ip net.IP, port uint64) error { conn, err := net.DialTimeout("tcp", address, 2*time.Second) if err != nil { return err - } defer conn.Close() return nil @@ -186,7 +185,7 @@ func (a *API) PortHandler(w http.ResponseWriter, r *http.Request) *appError { if err != nil { return internalServerError(err).AsJSON() } - err = testPort(ip, port) + err = a.testPort(ip, port) response := TestPortResponse{ IP: ip, Port: port, diff --git a/api/api_test.go b/api/api_test.go index a4b32b2..ceef36d 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -86,7 +86,7 @@ func TestJSONHandlers(t *testing.T) { status int }{ {s.URL, `{"ip":"127.0.0.1","country":"Elbonia","hostname":"localhost"}`, 200}, - {s.URL + "/port/8080", `{"ip":"127.0.0.1","port":8080,"reachable":false}`, 200}, + {s.URL + "/port/31337", `{"ip":"127.0.0.1","port":31337,"reachable":true}`, 200}, {s.URL + "/foo", `{"error":"404 page not found"}`, 404}, }