Skip to content

Commit dec2c92

Browse files
committed
Remove vestigial createTable function
1 parent b8358f8 commit dec2c92

File tree

2 files changed

+17
-30
lines changed

2 files changed

+17
-30
lines changed

lib/deploy-client.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,6 @@ const
99
//
1010
// Private functions
1111
//
12-
function createTable(tableName) {
13-
return this.knex.schema.createTable(tableName, tbl => {
14-
tbl.increments();
15-
tbl.string('key').notNullable()
16-
.unique();
17-
tbl.text('value').notNullable();
18-
tbl.binary('gitsha', 20); // reserved for future use
19-
tbl.string('deployer'); // reserved for future use
20-
tbl.string('description'); // reserved for future use
21-
tbl.boolean('is_active').notNullable()
22-
.defaultTo(false)
23-
.index();
24-
tbl.timestamp('created_at').notNullable()
25-
.defaultTo(this.knex.fn.now());
26-
});
27-
}
28-
2912
function listRevisions(tableName) {
3013
return this.knex(tableName)
3114
.orderBy('created_at', 'desc')

tests/unit/deploy-client-test.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ const rewire = require('rewire');
77
const subject = rewire('../../lib/deploy-client');
88

99
describe('DeployClient private methods', function() {
10-
const rewire = require('rewire');
11-
const subject = rewire('../../lib/deploy-client');
12-
1310
const knex = require('knex')({
1411
client: 'sqlite3',
1512
connection: { filename: ':memory:' },
1613
useNullAsDefault: true,
1714
//debug: true
1815
});
1916

20-
beforeEach(subject.__get__('createTable').bind({ knex }, 'test'));
21-
afterEach(() => knex.schema.dropTable('test'));
17+
beforeEach(() => {
18+
global.TABLE_NAME = 'test';
19+
20+
return knex.migrate.latest();
21+
});
22+
23+
afterEach(() => {
24+
global.TABLE_NAME = 'test';
25+
26+
return knex.migrate.rollback();
27+
});
2228

2329
// Tear down the connection pool after all the tests have completed.
2430
after(() => knex.destroy());
@@ -322,8 +328,6 @@ describe('DeployClient public API', function() {
322328
allowOverwrite: false
323329
};
324330

325-
const createTable = subject.__get__('createTable');
326-
327331
let deployClient;
328332

329333
afterEach(() => {
@@ -379,7 +383,7 @@ describe('DeployClient public API', function() {
379383
it('returns successfully', function() {
380384
deployClient = new subject(baseOptions);
381385

382-
return createTable.call(deployClient, 'foo')
386+
return deployClient.sanityCheck({ tableName: 'foo' })
383387
.then(() => deployClient.fetchRevisions({ tableName: 'foo' }));
384388
});
385389
});
@@ -388,7 +392,7 @@ describe('DeployClient public API', function() {
388392
it('returns the active revision key', function() {
389393
deployClient = new subject(baseOptions);
390394

391-
return createTable.call(deployClient, 'foo')
395+
return deployClient.sanityCheck({ tableName: 'foo' })
392396
.then(() => deployClient.knex('foo').insert([
393397
{ key: 'first', value: 'foo', is_active: false },
394398
{ key: 'second', value: 'bar', is_active: true },
@@ -403,7 +407,7 @@ describe('DeployClient public API', function() {
403407
it('returns null if no revision keys are active', function() {
404408
deployClient = new subject(baseOptions);
405409

406-
return createTable.call(deployClient, 'foo')
410+
return deployClient.sanityCheck({ tableName: 'foo' })
407411
.then(() => deployClient.knex('foo').insert({ key: 'foo', value: 'bar' }))
408412
.then(() => deployClient.activeRevisionKey({ tableName: 'foo' }))
409413
.then(key => {
@@ -416,7 +420,7 @@ describe('DeployClient public API', function() {
416420
it('activates a valid revision', function() {
417421
deployClient = new subject(baseOptions);
418422

419-
return createTable.call(deployClient, 'foo')
423+
return deployClient.sanityCheck({ tableName: 'foo' })
420424
.then(() => deployClient.knex('foo').insert({ key: 'foo', value: 'bar' }))
421425
.then(() => deployClient.activateRevision({ tableName: 'foo', revisionKey: 'foo' }))
422426
.then(() => deployClient.knex('foo').select('key').where('is_active', true))
@@ -434,7 +438,7 @@ describe('DeployClient public API', function() {
434438
it('will not activate an invalid revision', function() {
435439
deployClient = new subject(baseOptions);
436440

437-
return createTable.call(deployClient, 'foo')
441+
return deployClient.sanityCheck({ tableName: 'foo' })
438442
.then(() => {
439443
let promise = deployClient.activateRevision({ tableName: 'foo', revisionKey: 'foo' });
440444

@@ -484,7 +488,7 @@ describe('DeployClient public API', function() {
484488
{ key: 'third', value: 'qux', created_at: 3 }
485489
];
486490

487-
return createTable.call(deployClient, 'foo')
491+
return deployClient.sanityCheck({ tableName: 'foo' })
488492
.then(() => deployClient.knex('foo').insert(revisionList))
489493
.then(() => deployClient.upload({ tableName: 'foo', revisionKey: 'fourth', value: 'wat' }))
490494
.then(() => deployClient.knex('foo').select('key', 'value').orderBy('created_at'))

0 commit comments

Comments
 (0)