@@ -530,12 +530,14 @@ describe("dataSourceCommand2", () => {
530530 let getDataInsightsStub ,
531531 handleWSResultsStub ,
532532 handleScratchpadTableRes ,
533+ isUDAAvailableStub ,
533534 parseErrorStub : sinon . SinonStub ;
534535
535536 beforeEach ( ( ) => {
536537 getDataInsightsStub = sinon . stub ( insightsConn , "getDatasourceQuery" ) ;
537538 handleWSResultsStub = sinon . stub ( queryUtils , "handleWSResults" ) ;
538539 parseErrorStub = sinon . stub ( dataSourceCommand , "parseError" ) ;
540+ isUDAAvailableStub = sinon . stub ( insightsConn , "isUDAAvailable" ) ;
539541 handleScratchpadTableRes = sinon . stub (
540542 queryUtils ,
541543 "handleScratchpadTableRes" ,
@@ -547,6 +549,7 @@ describe("dataSourceCommand2", () => {
547549 } ) ;
548550
549551 it ( "should call the API and handle the results" , async ( ) => {
552+ isUDAAvailableStub . resolves ( true ) ;
550553 getDataInsightsStub . resolves ( { arrayBuffer : true } ) ;
551554 handleWSResultsStub . resolves ( [
552555 { a : "2" , b : "3" } ,
@@ -574,6 +577,7 @@ describe("dataSourceCommand2", () => {
574577 } ) ;
575578
576579 it ( "should call the API and handle the error results" , async ( ) => {
580+ isUDAAvailableStub . resolves ( true ) ;
577581 getDataInsightsStub . resolves ( { error : "error test" } ) ;
578582 parseErrorStub . resolves ( { error : "error test" } ) ;
579583
@@ -586,6 +590,7 @@ describe("dataSourceCommand2", () => {
586590 } ) ;
587591
588592 it ( "should call the API and handle undefined response " , async ( ) => {
593+ isUDAAvailableStub . resolves ( true ) ;
589594 getDataInsightsStub . resolves ( undefined ) ;
590595
591596 const result = await dataSourceCommand . runUDADataSource (
@@ -596,6 +601,46 @@ describe("dataSourceCommand2", () => {
596601 assert . deepStrictEqual ( result , { error : "UDA call failed" } ) ;
597602 } ) ;
598603
604+ it ( "should handle if the UDA doesn't exist in the connection" , async ( ) => {
605+ isUDAAvailableStub . resolves ( false ) ;
606+ getDataInsightsStub . resolves ( undefined ) ;
607+
608+ const result = await dataSourceCommand . runUDADataSource (
609+ dummyDataSourceFiles ,
610+ insightsConn ,
611+ ) ;
612+
613+ assert . deepStrictEqual ( result , {
614+ error : "UDA test query is not available in this connection" ,
615+ } ) ;
616+ } ) ;
617+
618+ it ( "should handle if a required param is empty" , async ( ) => {
619+ isUDAAvailableStub . resolves ( true ) ;
620+ getDataInsightsStub . resolves ( undefined ) ;
621+
622+ const dummyDSFiles2 = dummyDataSourceFiles ;
623+ dummyDSFiles2 . dataSource . uda . params = [
624+ {
625+ name : "param1" ,
626+ description : "test param" ,
627+ default : "" ,
628+ isReq : true ,
629+ type : [ 0 ] ,
630+ value : "" ,
631+ } ,
632+ ] ;
633+
634+ const result = await dataSourceCommand . runUDADataSource (
635+ dummyDSFiles2 ,
636+ insightsConn ,
637+ ) ;
638+
639+ assert . deepStrictEqual ( result , {
640+ error : "The UDA required the parameter param1." ,
641+ } ) ;
642+ } ) ;
643+
599644 it ( "should handle undefined UDA " , async ( ) => {
600645 dummyDataSourceFiles . dataSource . uda = undefined ;
601646
0 commit comments