mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
36 lines
558 B
Go
36 lines
558 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"encoding/json"
|
|
)
|
|
|
|
type TestSource struct {
|
|
Inputs map[string]string
|
|
Expectation string
|
|
}
|
|
|
|
func NewTestSource(source string) *TestSource {
|
|
s := &TestSource{}
|
|
err := json.Unmarshal([]byte(source), s)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
|
|
return s
|
|
}
|
|
|
|
type TestRunner struct {
|
|
source *TestSource
|
|
}
|
|
|
|
func NewTestRunner(t *testing.T) *TestRunner {
|
|
return &TestRunner{}
|
|
}
|
|
|
|
func (runner *TestRunner) RunFromString(input string, Cb func(*TestSource)) {
|
|
source := NewTestSource(input)
|
|
Cb(source)
|
|
}
|