|
| 1 | +/*! |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. |
| 4 | + */ |
| 5 | + |
| 6 | +import {} from 'mocha'; |
| 7 | +import {DataSourceHelper} from '../src/datasourcehelper'; |
| 8 | +import {OrchestratorDataSourceSettings} from '../src/settings'; |
| 9 | +import * as path from 'path'; |
| 10 | +import * as fs from 'fs-extra'; |
| 11 | +import assert = require('assert'); |
| 12 | + |
| 13 | +describe('DataSourceHelperTests', () => { |
| 14 | + const cwd: string = process.cwd(); |
| 15 | + it('getInputFolderPathWithDispatchFileInput', () => { |
| 16 | + const dataSourceSettings: OrchestratorDataSourceSettings = new OrchestratorDataSourceSettings([], true, ''); |
| 17 | + const input: string = DataSourceHelper.getInputFolderPath(path.join(cwd, 'test.Dispatch'), cwd, dataSourceSettings); |
| 18 | + assert(input === path.join(cwd, 'dataSources')); |
| 19 | + }); |
| 20 | + |
| 21 | + it('getInputFolderPathWithNoInputAndWithExistingOrchestratorSettingsFile', () => { |
| 22 | + const dataSourceSettings: OrchestratorDataSourceSettings = new OrchestratorDataSourceSettings([], true, path.join(cwd, 'dataSources')); |
| 23 | + const input: string = DataSourceHelper.getInputFolderPath('', cwd, dataSourceSettings); |
| 24 | + assert(input === dataSourceSettings.path); |
| 25 | + }); |
| 26 | + |
| 27 | + it('getInputFolderPathWithInputAndWithExistingOrchestratorSettingsFile', () => { |
| 28 | + const inputPath: string = path.resolve('./test/fixtures/output/dataSources'); |
| 29 | + fs.mkdirSync(inputPath, {recursive: true}); |
| 30 | + const dataSourceSettings: OrchestratorDataSourceSettings = new OrchestratorDataSourceSettings([], true, path.join(cwd, 'dataSources')); |
| 31 | + const input: string = DataSourceHelper.getInputFolderPath(inputPath, cwd, dataSourceSettings); |
| 32 | + assert(input === inputPath); |
| 33 | + assert(dataSourceSettings.path === inputPath); |
| 34 | + }); |
| 35 | +}); |
0 commit comments