UNPKG

hana-cli

Version:
216 lines (172 loc) 6.4 kB
// @ts-nocheck import * as chai from 'chai' import * as chaiAsPromised from 'chai-as-promised' import sinon from 'sinon' chai.use(chaiAsPromised.default) const expect = chai.expect /** * @test Data Diff Tests * Test suite for the dataDiff functionality */ describe('@all @dataDiff', () => { let dataDiffCmd let sandbox beforeEach(async () => { sandbox = sinon.createSandbox() dataDiffCmd = await import('../bin/dataDiff.js') }) afterEach(() => { sandbox.restore() }) describe('dataDiff command structure', () => { it('should have command property set to "dataDiff"', () => { expect(dataDiffCmd.command).to.equal('dataDiff') }) it('should have aliases property', () => { expect(dataDiffCmd.aliases).to.be.an('array') expect(dataDiffCmd.aliases).to.include('ddiff') expect(dataDiffCmd.aliases).to.include('diffData') }) it('should have describe property', () => { expect(dataDiffCmd.describe).to.exist }) it('should have builder property', () => { expect(dataDiffCmd.builder).to.be.a('function') }) it('should have handler property', () => { expect(dataDiffCmd.handler).to.be.a('function') }) it('should have inputPrompts property', () => { expect(dataDiffCmd.inputPrompts).to.be.an('object') expect(dataDiffCmd.inputPrompts).to.have.property('table1') expect(dataDiffCmd.inputPrompts).to.have.property('table2') expect(dataDiffCmd.inputPrompts).to.have.property('keyColumns') }) }) describe('diff parameters', () => { it('should require table1 parameter', () => { expect(dataDiffCmd.inputPrompts.table1.required).to.equal(true) }) it('should require table2 parameter', () => { expect(dataDiffCmd.inputPrompts.table2.required).to.equal(true) }) it('should require keyColumns parameter', () => { expect(dataDiffCmd.inputPrompts.keyColumns.required).to.equal(true) }) it('should have optional schema1 parameter', () => { expect(dataDiffCmd.inputPrompts.schema1).to.exist expect(dataDiffCmd.inputPrompts.schema1.required).to.equal(false) }) it('should have optional schema2 parameter', () => { expect(dataDiffCmd.inputPrompts.schema2).to.exist expect(dataDiffCmd.inputPrompts.schema2.required).to.equal(false) }) it('should have optional compareColumns filter', () => { expect(dataDiffCmd.inputPrompts.compareColumns).to.exist }) }) describe('output format options', () => { it('should support JSON output format', () => { const formats = ['json', 'csv', 'summary'] expect(formats).to.include('json') }) it('should support CSV output format', () => { const formats = ['json', 'csv', 'summary'] expect(formats).to.include('csv') }) it('should support summary output format', () => { const formats = ['json', 'csv', 'summary'] expect(formats).to.include('summary') }) it('should default to summary format', () => { // Default configured in builder expect(dataDiffCmd.inputPrompts.format).to.exist }) }) describe('diff analysis features', () => { it('should detect identical rows', () => { expect(dataDiffCmd.inputPrompts).to.exist }) it('should detect rows with differences', () => { expect(dataDiffCmd.inputPrompts).to.exist }) it('should detect rows only in table1', () => { expect(dataDiffCmd.inputPrompts).to.exist }) it('should detect rows only in table2', () => { expect(dataDiffCmd.inputPrompts).to.exist }) it('should show actual values in report if requested', () => { expect(dataDiffCmd.inputPrompts.showValues).to.exist }) }) describe('row matching', () => { it('should support single key column', () => { expect(dataDiffCmd.inputPrompts.keyColumns.type).to.equal('string') }) it('should support multiple key columns', () => { expect(dataDiffCmd.inputPrompts.keyColumns.type).to.equal('string') }) it('should accept comma-separated key columns', () => { expect(dataDiffCmd.inputPrompts.keyColumns.type).to.equal('string') }) }) describe('output options', () => { it('should support file output for diff results', () => { expect(dataDiffCmd.inputPrompts.output).to.exist }) it('should support row limit configuration', () => { expect(dataDiffCmd.inputPrompts.limit).to.exist }) it('should support timeout configuration', () => { expect(dataDiffCmd.inputPrompts.timeout).to.exist }) it('should support profile parameter', () => { expect(dataDiffCmd.inputPrompts.profile).to.exist }) }) describe('command aliases', () => { it('should support "ddiff" alias', () => { expect(dataDiffCmd.aliases).to.include('ddiff') }) it('should support "diffData" alias', () => { expect(dataDiffCmd.aliases).to.include('diffData') }) }) describe('handler function', () => { it('should be an async function', () => { expect(dataDiffCmd.handler.constructor.name).to.equal('AsyncFunction') }) }) describe('column-level difference tracking', () => { it('should identify specific columns that differ', () => { expect(dataDiffCmd.inputPrompts.compareColumns).to.exist }) it('should show both table values for changed columns', () => { expect(dataDiffCmd.inputPrompts).to.exist }) it('should support selective column comparison', () => { expect(dataDiffCmd.inputPrompts.compareColumns).to.exist }) }) describe('cross-schema diff', () => { it('should support comparing tables from different schemas', () => { expect(dataDiffCmd.inputPrompts.schema1).to.exist expect(dataDiffCmd.inputPrompts.schema2).to.exist }) it('should allow same-schema comparison', () => { expect(dataDiffCmd.inputPrompts.schema1.required).to.equal(false) }) }) describe('reporting options', () => { it('should show change summary by default', () => { expect(dataDiffCmd.inputPrompts.format).to.exist }) it('should allow detailed value reporting', () => { expect(dataDiffCmd.inputPrompts.showValues).to.exist }) it('should support file-based reporting', () => { expect(dataDiffCmd.inputPrompts.output).to.exist }) }) })