Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve failures readability when testing exprs #426

Merged
merged 1 commit into from
Jul 30, 2021
Merged

Conversation

jhchabran
Copy link
Collaborator

@jhchabran jhchabran commented Jul 30, 2021

With a bunch of t.Helpers() and line numbering, it's now much better. Because the originating file path (the sql) is absolute, you can click on it within your editor to open it (ignore the truncated version in the example below, it's a proper path in the code).

--- FAIL: TestMathFunctions (0.00s)
    --- FAIL: TestMathFunctions/math.floor (0.00s)
        --- FAIL: TestMathFunctions/math.floor/OK_@#math.floor(2.3) (0.00s)
            math_test.go:11:
                        Error Trace:    expr.go:160
                        Error:          Received unexpected error:
                                        found @, expected  at line 1, char 1
                        Test:           TestMathFunctions/math.floor/OK_@#math.floor(2.3)
                        Messages:       parse error at (/home/...)/testdata/math_functions.sql:2
                                        `@#math.floor(2.3)`
    --- FAIL: TestMathFunctions/math.abs (0.00s)
        --- FAIL: TestMathFunctions/math.abs/NOK_math.abs('foo') (0.00s)
            math_test.go:11:
                        Error Trace:    expr.go:180
                        Error:          Expect "cannot cast "foo" as double: strconv.ParseFloat: parsing "foo": invalid syntax" to match "cwfpwannot cast "foo" as double"
                        Test:           TestMathFunctions/math.abs/NOK_math.abs('foo')
                        Messages:       expected error message to match at (/home/...)/testdata/math_functions.sql:19

Copy link
Collaborator

@asdine asdine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@jhchabran jhchabran merged commit 402b5a6 into main Jul 30, 2021
@jhchabran jhchabran deleted the improve-testexpr branch July 30, 2021 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants