forked from advplyr/audiobookshelf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix isdownloadable tests and update version in filename
- Loading branch information
Showing
2 changed files
with
61 additions
and
42 deletions.
There are no files selected for viewing
42 changes: 0 additions & 42 deletions
42
test/server/migrations/v2.17.3-share-add-isdownloadable.test.js
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
test/server/migrations/v2.17.6-share-add-isdownloadable.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const chai = require('chai') | ||
const sinon = require('sinon') | ||
const { expect } = chai | ||
|
||
const { DataTypes } = require('sequelize') | ||
|
||
const { up, down } = require('../../../server/migrations/v2.17.6-share-add-isdownloadable') | ||
|
||
describe('Migration v2.17.6-share-add-isDownloadable', () => { | ||
let queryInterface, logger | ||
|
||
beforeEach(() => { | ||
queryInterface = { | ||
addColumn: sinon.stub().resolves(), | ||
removeColumn: sinon.stub().resolves(), | ||
tableExists: sinon.stub().resolves(true), | ||
describeTable: sinon.stub().resolves({ isDownloadable: undefined }) | ||
} | ||
|
||
logger = { | ||
info: sinon.stub(), | ||
error: sinon.stub() | ||
} | ||
}) | ||
|
||
describe('up', () => { | ||
it('should add the isDownloadable column to mediaItemShares table', async () => { | ||
await up({ context: { queryInterface, logger } }) | ||
|
||
expect(queryInterface.addColumn.calledOnce).to.be.true | ||
expect( | ||
queryInterface.addColumn.calledWith('mediaItemShares', 'isDownloadable', { | ||
type: DataTypes.BOOLEAN, | ||
defaultValue: false, | ||
allowNull: false | ||
}) | ||
).to.be.true | ||
|
||
expect(logger.info.calledWith('[2.17.6 migration] UPGRADE BEGIN: 2.17.6-share-add-isdownloadable')).to.be.true | ||
expect(logger.info.calledWith('[2.17.6 migration] Adding isDownloadable column to mediaItemShares table')).to.be.true | ||
expect(logger.info.calledWith('[2.17.6 migration] Added isDownloadable column to mediaItemShares table')).to.be.true | ||
expect(logger.info.calledWith('[2.17.6 migration] UPGRADE END: 2.17.6-share-add-isdownloadable')).to.be.true | ||
}) | ||
}) | ||
|
||
describe('down', () => { | ||
it('should remove the isDownloadable column from mediaItemShares table', async () => { | ||
queryInterface.describeTable.resolves({ isDownloadable: true }) | ||
|
||
await down({ context: { queryInterface, logger } }) | ||
|
||
expect(queryInterface.removeColumn.calledOnce).to.be.true | ||
expect(queryInterface.removeColumn.calledWith('mediaItemShares', 'isDownloadable')).to.be.true | ||
|
||
expect(logger.info.calledWith('[2.17.6 migration] DOWNGRADE BEGIN: 2.17.6-share-add-isdownloadable')).to.be.true | ||
expect(logger.info.calledWith('[2.17.6 migration] Removing isDownloadable column from mediaItemShares table')).to.be.true | ||
expect(logger.info.calledWith('[2.17.6 migration] Removed isDownloadable column from mediaItemShares table')).to.be.true | ||
expect(logger.info.calledWith('[2.17.6 migration] DOWNGRADE END: 2.17.6-share-add-isdownloadable')).to.be.true | ||
}) | ||
}) | ||
}) |