core: Remove fallback for subtests before Go 1.7
This commit is contained in:
parent
02c5942843
commit
b0be7f4cb3
|
@ -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)
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -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)
|
||||||
|
|
||||||
ctrl := gomock.NewController(t)
|
|
||||||
defer ctrl.Finish()
|
defer ctrl.Finish()
|
||||||
|
|
||||||
store := NewMockFullDataStore(ctrl)
|
store := NewMockFullDataStore(ctrl)
|
||||||
|
|
||||||
runTest(t, store)
|
runTest(subT, store)
|
||||||
|
})
|
||||||
if t.Failed() {
|
|
||||||
fmt.Println(p, "--- FAIL SubTest:", name)
|
|
||||||
t.FailNow()
|
|
||||||
} else {
|
|
||||||
fmt.Println(p, "--- PASS SubTest:", name)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue