@@ -9,10 +9,9 @@ import assert = require('assert');
99import * as path from 'path' ;
1010import * as fs from 'fs-extra' ;
1111
12- import { OrchestratorSettings } from '../src/settings' ;
12+ import { OrchestratorDataSource , OrchestratorSettings } from '../src/settings' ;
1313
1414import { Utility } from '../src/utility' ;
15- import { UnitTestHelper } from './utility.test' ;
1615
1716describe ( 'OrchestratorSettingsTests' , ( ) => {
1817 const SettingsDir : string = './test/fixtures/' ;
@@ -44,10 +43,15 @@ describe('OrchestratorSettingsTests', () => {
4443 assert . ok ( OrchestratorSettings . SettingsPath === SettingsFile ) ;
4544 assert . ok ( OrchestratorSettings . ModelPath === BaseModelDir ) ;
4645 assert . ok ( OrchestratorSettings . EntityModelPath === '' ) ;
46+ assert . ok ( ! OrchestratorSettings . DataSources ) ;
47+ } ) ;
4748
48- Utility . resetFlagToPrintDebuggingLogToConsole ( UnitTestHelper . getDefaultUnitTestDebuggingLogFlag ( ) ) ;
49- Utility . debuggingLog ( `OrchestratorSettings.DataSources.Path=${ OrchestratorSettings . DataSources . path } ` ) ;
50-
49+ it ( 'init settings with no settings file + data source' , ( ) => {
50+ OrchestratorSettings . init ( SettingsDir , BaseModelDir , '' , SettingsDir , false , true ) ;
51+ assert . ok ( OrchestratorSettings . SettingsPath === SettingsFile ) ;
52+ assert . ok ( OrchestratorSettings . ModelPath === BaseModelDir ) ;
53+ assert . ok ( OrchestratorSettings . EntityModelPath === '' ) ;
54+ assert . ok ( OrchestratorSettings . DataSources ) ;
5155 assert . ok ( OrchestratorSettings . DataSources . path === DataSourcesPath ) ;
5256 assert . ok ( OrchestratorSettings . DataSources . inputs . length === 0 ) ;
5357 assert . ok ( OrchestratorSettings . DataSources . hierarchical === false ) ;
@@ -114,6 +118,27 @@ describe('OrchestratorSettingsTests', () => {
114118 assert . ok ( OrchestratorSettings . DataSources . inputs [ 0 ] . Type === 'qna' ) ;
115119 assert . ok ( OrchestratorSettings . DataSources . inputs [ 1 ] . Type === 'luis' ) ;
116120 assert . ok ( OrchestratorSettings . DataSources . hierarchical ) ;
121+
122+ const dataSource : OrchestratorDataSource = new OrchestratorDataSource (
123+ 'a5ee4d79-28e0-4757-a9f8-45ab64ee1f7e' ,
124+ 'LUISKEY' ,
125+ 'version' ,
126+ 'https://westus.api.cognitive.microsoft.com' ,
127+ 'luis' ,
128+ 'l_HomeAutomation' ,
129+ OrchestratorSettings . DataSources . path ) ;
130+
131+ OrchestratorSettings . addUpdateDataSource ( dataSource ) ;
132+ OrchestratorSettings . persist ( ) ;
133+ OrchestratorSettings . init ( SettingsDir , BaseModelDir , '' , SettingsDir ) ;
134+ assert . ok ( OrchestratorSettings . DataSources . hierarchical ) ;
135+ assert . ok ( OrchestratorSettings . DataSources . inputs . length === 3 ) ;
136+ assert . ok ( OrchestratorSettings . DataSources . inputs [ 0 ] . Type === 'qna' ) ;
137+ assert . ok ( OrchestratorSettings . DataSources . inputs [ 0 ] . Id === '213a48d3-855d-4083-af6d-339c03d497dd' ) ;
138+ assert . ok ( OrchestratorSettings . DataSources . inputs [ 1 ] . Type === 'luis' ) ;
139+ assert . ok ( OrchestratorSettings . DataSources . inputs [ 1 ] . Id === 'd06d7acf-a9ec-43e0-94c6-3b37ee313a21' ) ;
140+ assert . ok ( OrchestratorSettings . DataSources . inputs [ 2 ] . Type === 'luis' ) ;
141+ assert . ok ( OrchestratorSettings . DataSources . inputs [ 2 ] . Id === 'a5ee4d79-28e0-4757-a9f8-45ab64ee1f7e' ) ;
117142 } ) ;
118143
119144 it ( 'init settings with settings file' , ( ) => {
0 commit comments