core: Remove fallback for subtests before Go 1.7

This commit is contained in:
Marius 2019-06-11 16:29:31 +02:00
parent 02c5942843
commit b0be7f4cb3
2 changed files with 7 additions and 44 deletions

View File

@ -1,22 +0,0 @@
// +build go1.7
package tusd_test
import (
"testing"
"github.com/golang/mock/gomock"
)
func SubTest(t *testing.T, name string, runTest func(*testing.T, *MockFullDataStore)) {
t.Run(name, func(subT *testing.T) {
//subT.Parallel()
ctrl := gomock.NewController(subT)
defer ctrl.Finish()
store := NewMockFullDataStore(ctrl)
runTest(subT, store)
})
}

View File

@ -1,35 +1,20 @@
// +build !go1.7
package tusd_test
import (
"fmt"
"strings"
"testing"
"github.com/golang/mock/gomock"
)
var subTestDepth = 0
func SubTest(t *testing.T, name string, runTest func(*testing.T, *MockFullDataStore)) {
subTestDepth++
defer func() { subTestDepth-- }()
p := strings.Repeat("\t", subTestDepth)
t.Run(name, func(subT *testing.T) {
//subT.Parallel()
fmt.Println(p, "=== RUN SubTest:", name)
ctrl := gomock.NewController(subT)
defer ctrl.Finish()
ctrl := gomock.NewController(t)
defer ctrl.Finish()
store := NewMockFullDataStore(ctrl)
store := NewMockFullDataStore(ctrl)
runTest(t, store)
if t.Failed() {
fmt.Println(p, "--- FAIL SubTest:", name)
t.FailNow()
} else {
fmt.Println(p, "--- PASS SubTest:", name)
}
runTest(subT, store)
})
}