/** * Created by rain on 2015/11/11. */ 'use strict'; const dc = require('../lib/dc'); const should = require('should'); const path = require('path'); describe('dc test', function () { it('dc init sqlite', function (done) { let ctx = {}; let config = { url: "sqlite://sqlite:sqlite@localhost:5432/sqlite", opts: { storage: path.join(__dirname, 'test.sqlite') } }; let gen = dc({}, config); let genValue = gen(ctx, function () { }).next(); ctx.fs.should.be.a.Object; ctx.fs.dc.should.be.a.Object; ctx.fs.dc.orm.should.be.a.Object; (genValue.done === true).should.be.ok; done(); }); it('dc create model in sqlite', function (done) { let ctx = {}; let config = { url: "sqlite://sqlite:sqlite@localhost:5432/sqlite", opts: { storage: path.join(__dirname, 'test.sqlite') }, models: [require(path.join(__dirname, 'model'))] }; let gen = dc({}, config); let genValue = gen(ctx, function () { }).next(); (genValue.done === true).should.be.ok; let models = ctx.fs.dc.models; models.User.sync({force: true}).then(function () { // Table created models.User.create({ username: 'John', password: 'Hancock' }).then(function () { done(); }); }); }) });