go-ethereum/tests/helper/http.go

26 lines
358 B
Go
Raw Normal View History

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