op-geth/test_runner.go

36 lines
547 B
Go
Raw Normal View History

2014-01-01 14:49:38 +00:00
package main
import (
2014-01-11 14:27:08 +00:00
"encoding/json"
"fmt"
"testing"
2014-01-01 14:49:38 +00:00
)
type TestSource struct {
2014-01-11 14:27:08 +00:00
Inputs map[string]string
Expectation string
2014-01-01 14:49:38 +00:00
}
func NewTestSource(source string) *TestSource {
2014-01-11 14:27:08 +00:00
s := &TestSource{}
err := json.Unmarshal([]byte(source), s)
if err != nil {
fmt.Println(err)
}
2014-01-01 14:49:38 +00:00
2014-01-11 14:27:08 +00:00
return s
2014-01-01 14:49:38 +00:00
}
type TestRunner struct {
2014-01-11 14:27:08 +00:00
source *TestSource
2014-01-01 14:49:38 +00:00
}
func NewTestRunner(t *testing.T) *TestRunner {
2014-01-11 14:27:08 +00:00
return &TestRunner{}
2014-01-01 14:49:38 +00:00
}
func (runner *TestRunner) RunFromString(input string, Cb func(*TestSource)) {
2014-01-11 14:27:08 +00:00
source := NewTestSource(input)
Cb(source)
2014-01-01 14:49:38 +00:00
}