plugeth/tests/helper/http.go
2014-10-15 17:12:26 +02:00

26 lines
358 B
Go

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