From 8eeb9e33055335db016693f90f030a23ef79474b Mon Sep 17 00:00:00 2001 From: Peter BALIVET Date: Mon, 23 Jun 2025 16:16:02 +0200 Subject: [PATCH] Added v2.25.2 DB migration unit tests file --- ...2-add-ipaddress-to-playbacksession.test.js | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/server/migrations/v2.25.2-add-ipaddress-to-playbacksession.test.js diff --git a/test/server/migrations/v2.25.2-add-ipaddress-to-playbacksession.test.js b/test/server/migrations/v2.25.2-add-ipaddress-to-playbacksession.test.js new file mode 100644 index 00000000..e822767a --- /dev/null +++ b/test/server/migrations/v2.25.2-add-ipaddress-to-playbacksession.test.js @@ -0,0 +1,46 @@ +const chai = require('chai') +const sinon = require('sinon') +const { expect } = chai + +const { DataTypes } = require('sequelize') + +const { up, down } = require('../../../server/migrations/v2.25.2-add-ipaddress-to-playbacksession') + +describe('Migration v2.25.2-add-ipaddress-to-playbacksession', () => { + let queryInterface, logger + + beforeEach(() => { + queryInterface = { + addColumn: sinon.stub().resolves(), + removeColumn: sinon.stub().resolves() + } + + logger = { + info: sinon.stub(), + error: sinon.stub() + } + }) + + describe('up', () => { + it('should add the ipAddress column to playbackSessions table', async () => { + await up(queryInterface, logger) + + expect(queryInterface.addColumn.calledOnce).to.be.true + expect( + queryInterface.addColumn.calledWith('playbackSessions', 'ipAddress', { + type: DataTypes.STRING, + allowNull: true + }) + ).to.be.true + }) + }) + + describe('down', () => { + it('should remove the ipAddress column from playbackSessions table', async () => { + await down(queryInterface, logger) + + expect(queryInterface.removeColumn.calledOnce).to.be.true + expect(queryInterface.removeColumn.calledWith('playbackSessions', 'ipAddress')).to.be.true + }) + }) +})