@apistudio/apim-cli
Version:
CLI for API Management Products
113 lines (100 loc) • 5.37 kB
text/typescript
/**
* Copyright Super iPaaS Integration LLC, an IBM Company 2024
*/
// import { spawnSync } from 'node:child_process';
// import {EXECUTING_TESTS_SUCCESS,INVALID_ENV_VARIABLE_FORMAT} from '../../../src/constants/message-constants';
describe('Functional tests for the test 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 : '';
// const localDir= 'test/resources/apim/Test-assets';
// const asset_1='jul24:Sanity:1.0';
// const asset_2='dev:TestPayments:1.0';
// const asset_3='new:NewTestPayments2:1.1';
// test('should check for successful test execution for all projects in a localDir', () => {
// const result = spawnSync('node', ['dist/cli.js', 'apim', 'test','--all', '--localDir', localDir], { encoding: 'utf-8' });
// const expectedLogs = [
// EXECUTING_TESTS_SUCCESS,
// ];
// expectedLogs.forEach(log => {
// expect(result.stdout.trim()).toContain(log);
// });
// });
// test('should check for test execution for single project without deploying', () => {
// const result = spawnSync('node', ['dist/cli.js', 'apim', 'test', 'ProjectA', '--localDir', localDir], { encoding: 'utf-8' });
// const expectedLogs = [
// EXECUTING_TESTS_SUCCESS,
// ];
// expectedLogs.forEach(log => {
// expect(result.stdout.trim()).toContain(log);
// });
// });
// test('should check for test execution for multiple projects without deploying', () => {
// const result = spawnSync('node', ['dist/cli.js', 'apim', 'test', 'ProjectA,ProjectB', '--localDir', localDir], { encoding: 'utf-8' });
// const expectedLogs = [
// EXECUTING_TESTS_SUCCESS,
// ];
// expectedLogs.forEach(log => {
// expect(result.stdout.trim()).toContain(log);
// });
// });
// test('should check for test execution for specific asset without deploying', () => {
// const result = spawnSync('node', ['dist/cli.js', 'apim', 'test', 'ProjectA', '--names',asset_1, '--localDir', localDir], { encoding: 'utf-8' });
// const expectedLogs = [
// EXECUTING_TESTS_SUCCESS,
// ];
// expectedLogs.forEach(log => {
// expect(result.stdout.trim()).toContain(log);
// });
// });
// test('should check for test execution for multiple asset within a single project without deploying', () => {
// const result = spawnSync('node', ['dist/cli.js', 'apim', 'test', 'ProjectB', '--names', asset_2,asset_3 , '--localDir', localDir ], { encoding: 'utf-8' });
// const expectedLogs = [
// EXECUTING_TESTS_SUCCESS,
// ];
// expectedLogs.forEach(log => {
// expect(result.stdout.trim()).toContain(log);
// });
// });
// test('should check for test execution with --env option true', () => {
// const result = spawnSync('node', ['dist/cli.js', 'apim', 'test', 'ProjectA', '--localDir', localDir, '--env', 'hello=hi,method=POST'], { encoding: 'utf-8' });
// const expectedLogs = [
// EXECUTING_TESTS_SUCCESS
// ];
// expectedLogs.forEach(log => {
// expect(result.stdout.trim()).toContain(log);
// });
// });
// test('should check for test failure with invalid --env option true', () => {
// const result = spawnSync('node', ['dist/cli.js', 'apim', 'test', 'ProjectA', '--localDir', localDir, '--env', 'hello=hi,method='], { encoding: 'utf-8' });
// const expectedLogs = [
// INVALID_ENV_VARIABLE_FORMAT
// ];
// 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', 'test', 'ProjectA-1', '--localDir', localDir], { encoding: 'utf-8' });
// const expectedLogs = [
// 'Error searching valid asset files of kind: Test: The folder \'ProjectA-1\' is invalid or does not exist inside parent directory \'test/resources/apim/Test-assets\'',
// 'Test execution failed : The folder \'ProjectA-1\' is invalid or does not exist inside parent directory \'test/resources/apim/Test-assets\''
// ];
// 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', 'test', 'ProjectA', '--localDir', 'test/resources/apim/xyz', '--target', target, '--username', username, '--password', password], { encoding: 'utf-8' });
// const expectedLogs = [
// 'Error searching valid asset files of kind: Test: The folder \'ProjectA\' is invalid or does not exist inside parent directory \'test/resources/apim/xyz\'',
// 'Test execution failed : The folder \'ProjectA\' is invalid or does not exist inside parent directory \'test/resources/apim/xyz\''
// ];
// expectedLogs.forEach(log => {
// expect(result.stdout.trim()).toContain(log);
// });
// });
});