1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-07-03 04:38:38 -04:00

testing: Add GET, DELETE, PUT helper functions too

This commit is contained in:
2017-10-09 06:00:51 -04:00
parent 2decf765ac
commit 32ac18647b
3 changed files with 108 additions and 107 deletions

View File

@ -3,7 +3,6 @@ package handlers_test
import (
"fmt"
"github.com/aclindsa/moneygo/internal/handlers"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"net/url"
@ -28,22 +27,7 @@ func newSession(user *User) (*http.Client, error) {
func getSession(client *http.Client) (*handlers.Session, error) {
var s handlers.Session
response, err := client.Get(server.URL + "/session/")
if err != nil {
return nil, err
}
body, err := ioutil.ReadAll(response.Body)
response.Body.Close()
if err != nil {
return nil, err
}
err = (&s).Read(string(body))
if err != nil {
return nil, err
}
read(client, &s, "/session/", "session")
return &s, nil
}