diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-11 01:00:54 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-19 04:15:07 +0800 |
commit | 1b26d4f220689dac18d560a4c1ecb3b29d99deb0 (patch) | |
tree | 66bed6c2091770fc58476299691204bb30efb7a5 /tests/init.go | |
parent | e82100367f794856a8807b5fcfe9f0043902a294 (diff) | |
download | go-tangerine-1b26d4f220689dac18d560a4c1ecb3b29d99deb0.tar go-tangerine-1b26d4f220689dac18d560a4c1ecb3b29d99deb0.tar.gz go-tangerine-1b26d4f220689dac18d560a4c1ecb3b29d99deb0.tar.bz2 go-tangerine-1b26d4f220689dac18d560a4c1ecb3b29d99deb0.tar.lz go-tangerine-1b26d4f220689dac18d560a4c1ecb3b29d99deb0.tar.xz go-tangerine-1b26d4f220689dac18d560a4c1ecb3b29d99deb0.tar.zst go-tangerine-1b26d4f220689dac18d560a4c1ecb3b29d99deb0.zip |
Flatten helper directory
Diffstat (limited to 'tests/init.go')
-rw-r--r-- | tests/init.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/init.go b/tests/init.go new file mode 100644 index 000000000..b487f81c3 --- /dev/null +++ b/tests/init.go @@ -0,0 +1,53 @@ +package tests + +import ( + "encoding/json" + "io" + "io/ioutil" + // "log" + "net/http" + "os" + "testing" + + // logpkg "github.com/ethereum/go-ethereum/logger" +) + +// var Logger *logpkg.StdLogSystem +// var Log = logpkg.NewLogger("TEST") + +// func init() { +// Logger = logpkg.NewStdLogSystem(os.Stdout, log.LstdFlags, logpkg.InfoLevel) +// logpkg.AddLogSystem(Logger) +// } + +func readJSON(t *testing.T, reader io.Reader, value interface{}) { + data, err := ioutil.ReadAll(reader) + err = json.Unmarshal(data, &value) + if err != nil { + t.Error(err) + } +} + +func CreateHttpTests(t *testing.T, uri string, value interface{}) { + resp, err := http.Get(uri) + if err != nil { + t.Error(err) + + return + } + defer resp.Body.Close() + + readJSON(t, resp.Body, value) +} + +func CreateFileTests(t *testing.T, fn string, value interface{}) { + file, err := os.Open(fn) + if err != nil { + t.Error(err) + + return + } + defer file.Close() + + readJSON(t, file, value) +} |