Add t.Run and t.Helper to paths_test.go

Test: paths_test.go
Change-Id: Iea2b07815fe82a346c5384571ebc2b57538722cc
This commit is contained in:
Colin Cross 2018-02-22 13:48:13 -08:00
parent 32f3898f0b
commit dc75ae70f3
1 changed files with 13 additions and 6 deletions

View File

@ -110,17 +110,21 @@ var validatePathTestCases = append(commonValidatePathTestCases, []strsTestCase{
func TestValidateSafePath(t *testing.T) { func TestValidateSafePath(t *testing.T) {
for _, testCase := range validateSafePathTestCases { for _, testCase := range validateSafePathTestCases {
ctx := &configErrorWrapper{} t.Run(strings.Join(testCase.in, ","), func(t *testing.T) {
out := validateSafePath(ctx, testCase.in...) ctx := &configErrorWrapper{}
check(t, "validateSafePath", p(testCase.in), out, ctx.errors, testCase.out, testCase.err) out := validateSafePath(ctx, testCase.in...)
check(t, "validateSafePath", p(testCase.in), out, ctx.errors, testCase.out, testCase.err)
})
} }
} }
func TestValidatePath(t *testing.T) { func TestValidatePath(t *testing.T) {
for _, testCase := range validatePathTestCases { for _, testCase := range validatePathTestCases {
ctx := &configErrorWrapper{} t.Run(strings.Join(testCase.in, ","), func(t *testing.T) {
out := validatePath(ctx, testCase.in...) ctx := &configErrorWrapper{}
check(t, "validatePath", p(testCase.in), out, ctx.errors, testCase.out, testCase.err) out := validatePath(ctx, testCase.in...)
check(t, "validatePath", p(testCase.in), out, ctx.errors, testCase.out, testCase.err)
})
} }
} }
@ -133,6 +137,7 @@ func TestOptionalPath(t *testing.T) {
} }
func checkInvalidOptionalPath(t *testing.T, path OptionalPath) { func checkInvalidOptionalPath(t *testing.T, path OptionalPath) {
t.Helper()
if path.Valid() { if path.Valid() {
t.Errorf("Uninitialized OptionalPath should not be valid") t.Errorf("Uninitialized OptionalPath should not be valid")
} }
@ -150,9 +155,11 @@ func checkInvalidOptionalPath(t *testing.T, path OptionalPath) {
func check(t *testing.T, testType, testString string, func check(t *testing.T, testType, testString string,
got interface{}, err []error, got interface{}, err []error,
expected interface{}, expectedErr []error) { expected interface{}, expectedErr []error) {
t.Helper()
printedTestCase := false printedTestCase := false
e := func(s string, expected, got interface{}) { e := func(s string, expected, got interface{}) {
t.Helper()
if !printedTestCase { if !printedTestCase {
t.Errorf("test case %s: %s", testType, testString) t.Errorf("test case %s: %s", testType, testString)
printedTestCase = true printedTestCase = true