Hacker News new | ask | show | jobs
by robsutter 1688 days ago
I remember those days too - my sins were T-SQL and I remember those headaches quite clearly.

One huge difference today is that you can actually unit-test user-defined functions and stored procedures using the same tooling you use for your application code. That lends itself naturally to integration testing, and so on.

I wouldn't necessarily recommend taking it to the property-based testing extreme like I did just to see whether it worked (it does).

1 comments

> you can actually unit-test user-defined functions and stored procedures using the same tooling you use for your application code

Can you give an example of how this is possible, or what tools/services it's possible with? I can understand how it would work on UDFs, but not entirely sure how it would be possible for stored procedures, esp when they're often times doing something more complex than simple read operations.

Sure - here's an example using Jest to test the logic in UDFs: https://github.com/fauna-labs/fql-utilities/blob/main/tests/...

You can use Jest's before[All] and after[All] to do any required setup and teardown per usual.

For Fauna, UDFs and stored procedures are synonymous.