approvals / go-approval-tests

Apache License 2.0
86 stars 22 forks source link

TestParameterizedTestNames fails on Windows #21

Closed hjwk closed 3 years ago

hjwk commented 3 years ago

Go 1.16.3 Windows 10

$ go test
--- FAIL: TestParameterizedTestNames (0.00s)
    --- FAIL: TestParameterizedTestNames/Normal (0.00s)
        approval_name_test.go:28: test name is wrong in namer, got TestParameterizedTestNames/Normal
    --- FAIL: TestParameterizedTestNames/Long (0.00s)
        approval_name_test.go:28: test name is wrong in namer, got TestParameterizedTestNames/Long
    --- FAIL: TestParameterizedTestNames/Short (0.00s)
        approval_name_test.go:28: test name is wrong in namer, got TestParameterizedTestNames/Short
--- FAIL: TestParameterizedTests (0.00s)
    --- FAIL: TestParameterizedTests/Normal (0.00s)
        approvals.go:41: Failed Approval: received does not match approved.
    --- FAIL: TestParameterizedTests/Long (0.00s)
        approvals.go:41: Failed Approval: received does not match approved.
    --- FAIL: TestParameterizedTests/Short (0.00s)
        approvals.go:41: Failed Approval: received does not match approved

Looking into the code it appears that the problems stems from relying on os.pathSeparator in line 28 of approval_name.go

name = strings.ReplaceAll(name, string(os.PathSeparator), ".")