UNPKG

hana-cli

Version:
181 lines (144 loc) 5.51 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 Comparison Tests * Test suite for the compareData functionality */ describe('@all @compareData', () => { let compareDataCmd let sandbox beforeEach(async () => { sandbox = sinon.createSandbox() compareDataCmd = await import('../bin/compareData.js') }) afterEach(() => { sandbox.restore() }) describe('compareData command structure', () => { it('should have command property set to "compareData"', () => { expect(compareDataCmd.command).to.equal('compareData') }) it('should have aliases property', () => { expect(compareDataCmd.aliases).to.be.an('array') expect(compareDataCmd.aliases).to.include('cmpdata') }) it('should have describe property', () => { expect(compareDataCmd.describe).to.exist }) it('should have builder property', () => { expect(compareDataCmd.builder).to.be.a('function') }) it('should have handler property', () => { expect(compareDataCmd.handler).to.be.a('function') }) it('should have inputPrompts property', () => { expect(compareDataCmd.inputPrompts).to.be.an('object') expect(compareDataCmd.inputPrompts).to.have.property('sourceTable') expect(compareDataCmd.inputPrompts).to.have.property('targetTable') expect(compareDataCmd.inputPrompts).to.have.property('keyColumns') }) }) describe('comparison parameters', () => { it('should require sourceTable parameter', () => { expect(compareDataCmd.inputPrompts.sourceTable.required).to.equal(true) }) it('should require targetTable parameter', () => { expect(compareDataCmd.inputPrompts.targetTable.required).to.equal(true) }) it('should require keyColumns parameter', () => { expect(compareDataCmd.inputPrompts.keyColumns.required).to.equal(true) }) it('should have optional sourceSchema parameter', () => { expect(compareDataCmd.inputPrompts.sourceSchema.required).to.equal(false) }) it('should have optional targetSchema parameter', () => { expect(compareDataCmd.inputPrompts.targetSchema.required).to.equal(false) }) it('should have optional columns filter', () => { expect(compareDataCmd.inputPrompts.columns).to.exist }) it('should have output file option', () => { expect(compareDataCmd.inputPrompts.output).to.exist }) }) describe('comparison features', () => { it('should support multi-column key matching', () => { expect(compareDataCmd.inputPrompts.keyColumns).to.exist }) it('should support selective column comparison', () => { expect(compareDataCmd.inputPrompts.columns).to.exist }) it('should support match visibility toggle', () => { expect(compareDataCmd.inputPrompts.showMatches).to.exist }) it('should support row limiting', () => { expect(compareDataCmd.inputPrompts.limit).to.exist }) it('should support timeout configuration', () => { expect(compareDataCmd.inputPrompts).to.have.property('timeout') }) }) describe('outputOptions', () => { it('should support file output for comparison results', () => { expect(compareDataCmd.inputPrompts.output).to.exist }) it('should support profile parameter', () => { expect(compareDataCmd.inputPrompts.profile).to.exist }) }) describe('command aliases', () => { it('should support "cmpdata" alias', () => { expect(compareDataCmd.aliases).to.include('cmpdata') }) it('should support "compardata" alias', () => { expect(compareDataCmd.aliases).to.include('compardata') }) it('should support "dataCompare" alias', () => { expect(compareDataCmd.aliases).to.include('dataCompare') }) }) describe('handler function', () => { it('should be an async function', () => { expect(compareDataCmd.handler.constructor.name).to.equal('AsyncFunction') }) }) describe('cross-schema comparison', () => { it('should support comparing tables from different schemas', () => { expect(compareDataCmd.inputPrompts.sourceSchema).to.exist expect(compareDataCmd.inputPrompts.targetSchema).to.exist }) it('should allow same schema comparison', () => { expect(compareDataCmd.inputPrompts.sourceSchema.required).to.equal(false) }) }) describe('key column configuration', () => { it('should accept comma-separated key columns', () => { expect(compareDataCmd.inputPrompts.keyColumns.type).to.equal('string') }) it('should require at least one key column', () => { expect(compareDataCmd.inputPrompts.keyColumns.required).to.equal(true) }) }) describe('difference reporting', () => { it('should report matching rows count', () => { // Functionality verified in handler expect(compareDataCmd.inputPrompts).to.exist }) it('should report differing rows count', () => { // Functionality verified in handler expect(compareDataCmd.inputPrompts).to.exist }) it('should report source-only rows', () => { // Functionality verified in handler expect(compareDataCmd.inputPrompts).to.exist }) it('should report target-only rows', () => { // Functionality verified in handler expect(compareDataCmd.inputPrompts).to.exist }) }) })