quorum/tests/helper/http.go

26 lines
358 B
Go
Raw Normal View History

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