课程: Supabase Essential Training
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Unit tests
- [Instructor] Unit tests can help ensure the correctness of your SQL code. This can help ensure you have the tables and policies you're expecting. PostgreSQL has an extension called pgtap. This is available on the super base platform, so let's enable it. One thing to keep in mind is that you'll want to enable pgtap for the extension schema and not your public schema. Otherwise, the functions for pgtap will end up in your public schema, and that will make it difficult for you to find your custom defined functions. You also don't want the pgtap functions to become RPC endpoints. So let's just add this in the extension schema and enable. And pgtap is on. Now we're ready to go and write some unit tests. So let's go to the SQL editor, and I have a blank page ready to go here for my SQL. I'm going to start with begin, and then I'm going to end with rollback. This is important because it runs everything in a transaction so you can make any changes you want to any tables, add columns, insert…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。