本文介绍了在node.js中测试后清理数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每次它后如何清理数据库?
How I can clean database after each it?
在Rails中,我使用 github/bmabey/database_cleaner ,但我确实做到了找不到与node.js类似的东西
In rails I use github/bmabey/database_cleaner, but I did't find something similar for node.js
node.js(v0.10.26),PostgreSQL(9.3.3),mocha,restify和knex.
node.js (v0.10.26), PostgreSQL (9.3.3), mocha, restify and knex.
推荐答案我发现在测试之间清理数据库的简单方法是
The easy way I have found to clean the database between test is to
DROP SCHEMA public CASCADE; CREATE SCHEMA public AUTHORIZATION my_test_user;一旦公共模式属于测试用户,他就可以在需要时删除并重新创建模式.请注意,删除数据库公共模式中的所有内容.
Once the public schema belongs to the test user, he is able to drop and re-create the schema when needed. Be aware that drop everything that lies in your database's public schema.
更多推荐
在node.js中测试后清理数据库
发布评论