2016-10-13 10:29:13 +00:00
|
|
|
// +build !go1.7
|
|
|
|
|
|
|
|
package tusd_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2016-10-13 10:59:11 +00:00
|
|
|
"strings"
|
2016-10-13 10:29:13 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/golang/mock/gomock"
|
|
|
|
)
|
|
|
|
|
2016-10-13 10:59:11 +00:00
|
|
|
var subTestDepth = 0
|
|
|
|
|
2016-10-13 10:29:13 +00:00
|
|
|
func SubTest(t *testing.T, name string, runTest func(*testing.T, *MockFullDataStore)) {
|
2016-10-13 10:59:11 +00:00
|
|
|
subTestDepth++
|
|
|
|
defer func() { subTestDepth-- }()
|
|
|
|
p := strings.Repeat("\t", subTestDepth)
|
|
|
|
|
|
|
|
fmt.Println(p, "=== RUN SubTest:", name)
|
2016-10-13 10:29:13 +00:00
|
|
|
|
|
|
|
ctrl := gomock.NewController(t)
|
|
|
|
defer ctrl.Finish()
|
|
|
|
|
|
|
|
store := NewMockFullDataStore(ctrl)
|
|
|
|
|
|
|
|
runTest(t, store)
|
|
|
|
|
|
|
|
if t.Failed() {
|
2016-10-13 10:59:11 +00:00
|
|
|
fmt.Println(p, "--- FAIL SubTest:", name)
|
2016-10-13 10:29:13 +00:00
|
|
|
t.FailNow()
|
|
|
|
} else {
|
2016-10-13 10:59:11 +00:00
|
|
|
fmt.Println(p, "--- PASS SubTest:", name)
|
2016-10-13 10:29:13 +00:00
|
|
|
}
|
|
|
|
}
|