@@ -550,7 +550,7 @@ describe('qnamaker:build update knowledge base successfully with parameters set
550550 before ( async function ( ) {
551551 await fs . ensureDir ( path . join ( __dirname , './../../../results/' ) )
552552
553- nock ( 'https://westus .api.cognitive.microsoft.com ' )
553+ nock ( 'https://chinaeast2 .api.cognitive.azure.cn ' )
554554 . get ( uri => uri . includes ( 'qnamaker' ) )
555555 . reply ( 200 , {
556556 knowledgebases :
@@ -561,7 +561,7 @@ describe('qnamaker:build update knowledge base successfully with parameters set
561561 } ]
562562 } )
563563
564- nock ( 'https://westus .api.cognitive.microsoft.com ' )
564+ nock ( 'https://chinaeast2 .api.cognitive.azure.cn ' )
565565 . get ( uri => uri . includes ( 'knowledgebases' ) )
566566 . reply ( 200 , {
567567 qnaDocuments : [ {
@@ -573,15 +573,15 @@ describe('qnamaker:build update knowledge base successfully with parameters set
573573 } ]
574574 } )
575575
576- nock ( 'https://westus .api.cognitive.microsoft.com ' )
576+ nock ( 'https://chinaeast2 .api.cognitive.azure.cn ' )
577577 . put ( uri => uri . includes ( 'knowledgebases' ) )
578578 . reply ( 204 )
579579
580- nock ( 'https://westus .api.cognitive.microsoft.com ' )
580+ nock ( 'https://chinaeast2 .api.cognitive.azure.cn ' )
581581 . post ( uri => uri . includes ( 'knowledgebases' ) )
582582 . reply ( 204 )
583583
584- nock ( 'https://westus .api.cognitive.microsoft.com ' )
584+ nock ( 'https://chinaeast2 .api.cognitive.azure.cn ' )
585585 . get ( uri => uri . includes ( 'endpointkeys' ) )
586586 . reply ( 200 , {
587587 primaryEndpointKey : 'xxxx' ,
@@ -606,4 +606,72 @@ describe('qnamaker:build update knowledge base successfully with parameters set
606606 expect ( await compareFiles ( './../../../results/test.en-us.qna.dialog' , './../../fixtures/testcases/qnabuild/sandwich/dialogs/test.en-us.qna.dialog' ) ) . to . be . true
607607 expect ( await compareFiles ( './../../../results/test.qna.dialog' , './../../fixtures/testcases/qnabuild/sandwich/dialogs/test.qna.dialog' ) ) . to . be . true
608608 } )
609+ } )
610+
611+ describe ( 'qnamaker:build create a new knowledge base successfully with endpoint override' , ( ) => {
612+ before ( function ( ) {
613+ nock ( 'https://chinaeast2.api.cognitive.azure.cn' )
614+ . get ( uri => uri . includes ( 'qnamaker' ) )
615+ . reply ( 200 , {
616+ knowledgebases :
617+ [ {
618+ name : 'test.en-us.qna' ,
619+ id : 'f8c64e2a-1111-3a09-8f78-39d7adc76ec5' ,
620+ hostName : 'https://myqnamakerbot.azurewebsites.net'
621+ } ]
622+ } )
623+
624+ nock ( 'https://chinaeast2.api.cognitive.azure.cn' )
625+ . post ( uri => uri . includes ( 'createasync' ) )
626+ . reply ( 202 , {
627+ operationId : 'f8c64e2a-aaaa-3a09-8f78-39d7adc76ec5'
628+ } )
629+
630+ nock ( 'https://chinaeast2.api.cognitive.azure.cn' )
631+ . get ( uri => uri . includes ( 'operations' ) )
632+ . reply ( 200 , {
633+ operationState : 'Succeeded' ,
634+ resourceLocation : 'a/b/f8c64e2a-2222-3a09-8f78-39d7adc76ec5'
635+ } )
636+
637+ nock ( 'https://chinaeast2.api.cognitive.azure.cn' )
638+ . put ( uri => uri . includes ( 'knowledgebases' ) )
639+ . reply ( 204 )
640+
641+ nock ( 'https://chinaeast2.api.cognitive.azure.cn' )
642+ . post ( uri => uri . includes ( 'knowledgebases' ) )
643+ . reply ( 204 )
644+
645+ nock ( 'https://chinaeast2.api.cognitive.azure.cn' )
646+ . get ( uri => uri . includes ( 'knowledgebases' ) )
647+ . reply ( 200 , {
648+ id : 'f8c64e2a-1111-3a09-8f78-39d7adc76ec5' ,
649+ hostName : 'https://myqnamakerbot.azurewebsites.net'
650+ } )
651+
652+ nock ( 'https://chinaeast2.api.cognitive.azure.cn' )
653+ . put ( uri => uri . includes ( 'alterations' ) )
654+ . reply ( 204 )
655+
656+ nock ( 'https://chinaeast2.api.cognitive.azure.cn' )
657+ . get ( uri => uri . includes ( 'endpointkeys' ) )
658+ . reply ( 200 , {
659+ primaryEndpointKey : 'xxxx' ,
660+ secondaryEndpointKey : 'yyyy'
661+ } )
662+ } )
663+
664+ test
665+ . stdout ( )
666+ . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/sandwich/qnafiles/sandwich.en-us.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' , '--endpoint' , 'https://chinaeast2.api.cognitive.azure.cn/qnamaker/v4.0' ] )
667+ . it ( 'should create a new knowledge base successfully with endpoint override' , ctx => {
668+ expect ( ctx . stdout ) . to . contain ( 'Handling qnamaker knowledge bases...' )
669+ expect ( ctx . stdout ) . to . contain ( 'Creating qnamaker KB: test(development).en-us.qna...' )
670+ expect ( ctx . stdout ) . to . contain ( 'Creating finished' )
671+ expect ( ctx . stdout ) . to . contain ( 'Publishing kb' )
672+ expect ( ctx . stdout ) . to . contain ( 'Publishing finished' )
673+ expect ( ctx . stdout ) . to . contain ( 'Replacing alterations...' )
674+ expect ( ctx . stdout ) . to . contain ( 'xxxx' )
675+ expect ( ctx . stdout ) . to . contain ( 'yyyy' )
676+ } )
609677} )
0 commit comments