aboutsummaryrefslogtreecommitdiffstats
path: root/tests/init.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-06-11 04:10:33 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-06-19 04:20:44 +0800
commitc5d6fcbaba545d1078f5411dc67208d5d388222e (patch)
tree20d4e6592ba8411a0ab5980522029c4aac4a8244 /tests/init.go
parent24554629b162d20a1f945386a45e3221c58adc2b (diff)
downloadgo-tangerine-c5d6fcbaba545d1078f5411dc67208d5d388222e.tar.gz
go-tangerine-c5d6fcbaba545d1078f5411dc67208d5d388222e.tar.zst
go-tangerine-c5d6fcbaba545d1078f5411dc67208d5d388222e.zip
Return error up stack instead of passing testing var down
Diffstat (limited to 'tests/init.go')
-rw-r--r--tests/init.go33
1 files changed, 20 insertions, 13 deletions
diff --git a/tests/init.go b/tests/init.go
index b487f81c3..4a176698f 100644
--- a/tests/init.go
+++ b/tests/init.go
@@ -1,13 +1,14 @@
package tests
import (
+ "bytes"
"encoding/json"
+ "fmt"
"io"
"io/ioutil"
// "log"
"net/http"
"os"
- "testing"
// logpkg "github.com/ethereum/go-ethereum/logger"
)
@@ -20,34 +21,40 @@ import (
// logpkg.AddLogSystem(Logger)
// }
-func readJSON(t *testing.T, reader io.Reader, value interface{}) {
+func readJSON(reader io.Reader, value interface{}) error {
data, err := ioutil.ReadAll(reader)
err = json.Unmarshal(data, &value)
if err != nil {
- t.Error(err)
+ return err
}
+ return nil
}
-func CreateHttpTests(t *testing.T, uri string, value interface{}) {
+func CreateHttpTests(uri string, value interface{}) error {
resp, err := http.Get(uri)
if err != nil {
- t.Error(err)
-
- return
+ return err
}
defer resp.Body.Close()
- readJSON(t, resp.Body, value)
+ err = readJSON(resp.Body, value)
+ if err != nil {
+ return err
+ }
+ return nil
}
-func CreateFileTests(t *testing.T, fn string, value interface{}) {
+func CreateFileTests(fn string, value interface{}) error {
file, err := os.Open(fn)
if err != nil {
- t.Error(err)
-
- return
+ return err
}
defer file.Close()
- readJSON(t, file, value)
+ err = readJSON(file, value)
+ if err != nil {
+ return err
+ }
+ return nil
+}
}