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)
|
||||||
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue