diff --git a/testhelper.go b/testhelper.go index 4bee0c2..0b5486e 100644 --- a/testhelper.go +++ b/testhelper.go @@ -1,13 +1,13 @@ -package main; +package main import ( - "net/http" - "io/ioutil" "database/sql" - _ "github.com/lib/pq" - "os" - "log" "fmt" + _ "github.com/lib/pq" + "io/ioutil" + "log" + "net/http" + "os" ) func crash(err error) { @@ -24,14 +24,15 @@ func main() { account := r.PostFormValue("account") var code string err := db.QueryRow("SELECT verification_code FROM pending_accounts WHERE number = $1", account).Scan(&code) - if(err != nil) { - fmt.Printf(w, "\n") + if err != nil { + fmt.Fprintf(w, "An error occured: %s\n", err) + } else { + fmt.Fprintf(w, "%s\n", code) } - fmt.Fprintf(w, "%s\n", code) }) http.HandleFunc("/v1/directory/reconcile", func(w http.ResponseWriter, r *http.Request) { - b, err := ioutil.ReadAll(r.Body) + _, err := ioutil.ReadAll(r.Body) defer r.Body.Close() crash(err) w.Header().Set("Content-Type", "application/json")