UNPKG

@apistudio/apim-cli

Version:

CLI for API Management Products

90 lines (78 loc) 4.11 kB
/** * Copyright Super iPaaS Integration LLC, an IBM Company 2024 */ // Disabling functional tests as it depends on gateway availability and pr merge handler shouldn't be blocked for this reason /* import { spawnSync } from 'node:child_process'; import {DEPLOYMENT_SUCCESS, DEPLOYMENT_FAILURE} from '../../../src/constants/message-constants'; */ describe('Functional tests for the deploy command', () => { test('dummy test', () => { expect(true).toBe(true); }); /* const target = process.env.GATEWAY_TARGET !== undefined ? process.env.GATEWAY_TARGET : ''; const username = process.env.GATEWAY_USERNAME !== undefined ? process.env.GATEWAY_USERNAME : ''; const password = process.env.GATEWAY_PASSWORD !== undefined ? process.env.GATEWAY_PASSWORD : ''; test('should check for deployment success with archive file', () => { const result = spawnSync( 'node', ['dist/cli.js', 'apim', 'deploy', '--archive', 'test/resources/apim/deploy-asset.zip', '--target', target , '--username', username, '--password', password], { encoding: 'utf-8' }); const expectedLogs = [ DEPLOYMENT_SUCCESS, ]; expectedLogs.forEach(log => { expect(result.stdout.trim()).toContain(log); }); }); test('should check for deployment failure with archive file', () => { const result = spawnSync( 'node', ['dist/cli.js', 'apim', 'deploy', '--archive', 'test/resources/apim/deploy-asset.zip', '--target', target, '--username', username, '--password', ''], { encoding: 'utf-8' }); const expectedLogs = [ DEPLOYMENT_FAILURE, ]; expectedLogs.forEach(log => { expect(result.stdout.trim()).toContain(log); }); }); test('should check for deployment success with localDir and project arguments', () => { const result = spawnSync( 'node', ['dist/cli.js', 'apim', 'deploy', 'ProjectA', '--localDir', 'test/resources/apim/api-studio-root', '--target', target, '--username', username, '--password', password], { encoding: 'utf-8' }); const expectedLogs = [ DEPLOYMENT_SUCCESS, ]; expectedLogs.forEach(log => { expect(result.stdout.trim()).toContain(log); }); }); test('should check for deployment failure with localDir and project arguments', () => { const result = spawnSync( 'node', ['dist/cli.js', 'apim', 'deploy', 'ProjectA', '--localDir', 'test/resources/apim/api-studio-root', '--target', target, '--username', username, '--password', ''], { encoding: 'utf-8' }); const expectedLogs = [ DEPLOYMENT_FAILURE, ]; expectedLogs.forEach(log => { expect(result.stdout.trim()).toContain(log); }); }); test('should check for error when wrong project arguments are passed', () => { const result = spawnSync( 'node', ['dist/cli.js', 'apim', 'deploy', 'ProjectA-1', '--localDir', 'test/resources/apim/api-studio-root', '--target', target, '--username', username, '--password', password], { encoding: 'utf-8' }); const expectedLogs = [ 'The project \'ProjectA-1\' does not exists in the root directory - \'test/resources/apim/api-studio-root\'', ]; expectedLogs.forEach(log => { expect(result.stdout.trim()).toContain(log); }); }); test('should check for error when wrong localDir is passed', () => { const result = spawnSync( 'node', ['dist/cli.js', 'apim', 'deploy', 'ProjectA', '--localDir', 'test/resources/apim/api-studio', '--target', target, '--username', username, '--password', password], { encoding: 'utf-8' }); const expectedLogs = [ 'The root directory path \'test/resources/apim/api-studio\' is either not directory or does not exist.', ]; expectedLogs.forEach(log => { expect(result.stdout.trim()).toContain(log); }); }); test('should check if the existing assets are overwritten for deployment', () => { const result = spawnSync( 'node', ['dist/cli.js', 'apim', 'deploy', '--archive', 'test/resources/apim/deploy-asset.zip', '--target', target, '--username', username, '--password', password, '--overwrite'], { encoding: 'utf-8' }); const expectedLogs = [ DEPLOYMENT_SUCCESS, ]; expectedLogs.forEach(log => { expect(result.stdout.trim()).toContain(log); }); }); */ });