如何在流星中建立单独的测试和开发数据库

如何在流星中建立单独的测试和开发数据库

问题描述:

我已经为流星应用编写了一些测试.由于它们具有删除所有文档或填充新文档的设置和拆卸方法,因此,我希望在专用于测试的数据库上运行它们.

I've written a few tests for my meteor app. As they have setup and teardown methods that remove all documents or populate with new ones, I'd like to run them on a database dedicated to testing.

我注意到数据库存储在.meteor/local/db中.理想情况下,我想从不同的端口访问db_test和db_dev.

I notice the db is stored in .meteor/local/db . Ideally I'd like to have db_test and db_dev accessed form different ports.

这可能吗?

您将必须运行两个mongod进程,例如

You'll have to run two mongod processes e.g.

# Dev
mongod --port 27017 --dbpath .meteor/local/db_dev

# Testing
mongod --port 28017 --dbpath .meteor/local/db_test


这应该起作用.使用排行榜示例项目:


This should work. Using the leaderboard example project:
MONGO_URL="mongodb://127.0.0.1:27017/appname_dev" meteor run --port 3000
MONGO_URL="mongodb://127.0.0.1:28017/appname_test" meteor run --port 4000

这将使用单独的数据库.

That will use separate databases.