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