plugeth/tests/helper/http.go

26 lines
358 B
Go
Raw Normal View History

2014-10-14 22:41:00 +00:00
package helper
import (
"encoding/json"
"io/ioutil"
"net/http"
2014-10-15 15:12:26 +00:00
"testing"
2014-10-14 22:41:00 +00:00
)
2014-10-15 15:12:26 +00:00
func CreateTests(t *testing.T, uri string, value interface{}) {
2014-10-14 22:41:00 +00:00
resp, err := http.Get(uri)
if err != nil {
2014-10-15 15:12:26 +00:00
t.Error(err)
return
2014-10-14 22:41:00 +00:00
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
err = json.Unmarshal(data, &value)
if err != nil {
2014-10-15 15:12:26 +00:00
t.Error(err)
2014-10-14 22:41:00 +00:00
}
}