UNPKG

@house-agency/brewstore

Version:
78 lines (69 loc) 2.05 kB
// Hide logging require('@house-agency/brewtils/log').level('fatal'); // Load config file require('@house-agency/brewtils/config').load('test/test.json'); const assert = require('chai').assert; const expect = require('chai').expect; const q = require('q'); const relational = require('../relational'); const Sequelize = require('sequelize'); describe('Relational', () => { it('connect through config', done => { relational.then(database => { return database.showAllSchemas(); }) .then(schemas => { assert.isOk(schemas); }) .done(done); }); it('create a table', done => { relational.create_table( 'test_stuffs', { column: { type: Sequelize.STRING } }, q('dependent string').then(str => assert.isOk(str)) ) .then(table => { assert.isOk(table.findById); return relational .invoke('getQueryInterface') .invoke('describeTable', 'test_stuffs'); }) .then(columns => { expect(columns.column.type).to.equal('VARCHAR(255)'); }) .done(done); }); it('add a column to table', done => { relational.create_table( 'test_stuffs', { column: { type: Sequelize.STRING }, other_column: { type: Sequelize.INTEGER } } ) .then(table => { assert.isOk(table.findById); return relational .invoke('getQueryInterface') .invoke('describeTable', 'test_stuffs'); }) .then(columns => { expect(columns.other_column.type).to.equal('INT(11)'); }) .done(done); }); it('drop all tables', done => { relational.invoke('dropSchema', 'test_stuffs') .then(() => null) .done(done); }); });