用testing数据库testingStrongloop RESTapi
我正在使用Strongloop开发Web应用程序,该应用程序将在Bluemix(云平台服务)上运行。
我的问题是,当我testing我想testing运行对另一个数据库,而不是内存数据库。
我有两个问题关于如何做到这一点:
-
是/我该如何configuration一个特定的数据库应该在运行testing时使用? 作为部署的一部分,我希望能够在Bluemix上部署时运行testing。 所以,如果我没有错,这是不够的,如果我可以手动使用一些参数设置什么数据库将运行时,我正在做一个“节点”。
-
另外在我的server.js我这样做我的数据库同步我的datamodel:
var appModels = ['User']; var ds = app.dataSources.eventSeedElephantSQLDb; ds.isActual(appModels, function(err, actual) { if (!actual) { ds.autoupdate(appModels, function(err) { if (err) throw (err); }); } });
当我正在运行testing,我想运行类似的东西,而是我想迁移。
在testing中,我使用摩卡,柴和柴哈特。
您可以为testing创build一个“环境特定的configuration”。 请看: https : //docs.strongloop.com/display/public/LB/Environment-specific+configuration
例如,您可以创build另一个datasources.jsonconfiguration文件,但名称为datasources.test.json
{ "my-test-database": { "host": "localhost", "port": 27017, "database": "my-test-database", "connector": "mongodb" } }
在testing的第一行,你定义了环境
process.env.NODE_ENV = 'test'; //here I clean and create the data that I need, but you can use your database data beforeEach(function(done) { app.models['City'].destroyAll(); app.models['City'].create({name: 'city test', country: 'Brazil'}); }); describe('/city', function() { it('should find a city', function(done) { request(app).get('/api/city').expect(200); }); });
- Cloudant NodeJS出现意外的“server_admin required”错误
- 如何提取从createRecognizeStream()方法返回的值?
- IBM推送:不能在ibmpush.js中使用sendNotificationByDeviceIds
- 如何将包含NodeJs模块的Codeigniter应用程序部署到Bluemix?
- Node.js不能每三次刷新一次获取静态文件
- ERRInstance(索引0)无法开始接受连接
- 使用Typescript设置一个带有Angular 2前端的Node.js js服务器
- 如何避免Bluemixpipe道分段中的“设备上没有剩余空间”?
- 我可以在IBM Bluemix DevOps Services中使用不同版本的节点:构build“npm”构build器types?