aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helper/http.go
blob: 3c570d10686b6dd5128fb5d9413ba96f22511b24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)
    }
}