@@ -769,7 +769,7 @@ describe('Bigtable/Instance', () => {
769769 } ) ;
770770 } ) ;
771771
772- describe ( 'getApprofilesStream ' , ( ) => {
772+ describe ( 'getAppProfilesStream ' , ( ) => {
773773 let returnStream : PassThrough ;
774774 beforeEach ( ( ) => {
775775 returnStream = new PassThrough ( {
@@ -867,6 +867,87 @@ describe('Bigtable/Instance', () => {
867867 } ) ;
868868 } ) ;
869869
870+ it ( 'should return a decorated error with failedLocations list' , done => {
871+ let counter = 0 ;
872+ let failedLocations : string [ ] = [ ] ;
873+ const pages = [
874+ {
875+ appProfiles : [
876+ {
877+ name : '/projects/p/instances/i/appProfiles/profile-a' ,
878+ } ,
879+ {
880+ name : '/projects/p/instances/i/appProfiles/profile-b' ,
881+ } ,
882+ ] ,
883+ response : { failedLocations : [ ] } ,
884+ } ,
885+ {
886+ appProfiles : [
887+ {
888+ name : '/projects/p/instances/i/appProfiles/profile-c' ,
889+ } ,
890+ {
891+ name : '/projects/p/instances/i/appProfiles/profile-d' ,
892+ } ,
893+ ] ,
894+ response : { failedLocations : [ 'us-east1-a' ] } ,
895+ } ,
896+
897+ {
898+ appProfiles : [
899+ {
900+ name : '/projects/p/instances/i/appProfiles/profile-e' ,
901+ } ,
902+ {
903+ name : '/projects/p/instances/i/appProfiles/profile-f' ,
904+ } ,
905+ ] ,
906+ response : { failedLocations : [ 'us-west1-b' , 'us-west1-c' ] } ,
907+ } ,
908+ ] ;
909+
910+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
911+ ( instance . bigtable . request as Function ) = ( ) => {
912+ return returnStream ;
913+ } ;
914+
915+ setImmediate ( ( ) => {
916+ pages . forEach ( p => {
917+ failedLocations = failedLocations . concat ( p . response . failedLocations ) ;
918+ returnStream . emit ( 'response' , p . response ) ;
919+ p . appProfiles . forEach ( a => {
920+ returnStream . push ( a ) ;
921+ counter ++ ;
922+ } ) ;
923+ } ) ;
924+ returnStream . push ( null ) ;
925+ } ) ;
926+ const appProfiles : AppProfile [ ] = [ ] ;
927+ instance
928+ . getAppProfilesStream ( )
929+ . on ( 'error' , err => {
930+ assert . strictEqual ( appProfiles . length , counter ) ;
931+ console . log ( err . message ) ;
932+ assert . deepStrictEqual (
933+ err ,
934+ new Error (
935+ `Resources from the following locations are currently not available\n${ JSON . stringify (
936+ failedLocations
937+ ) } `
938+ )
939+ ) ;
940+ done ( ) ;
941+ } )
942+ . on ( 'data' , appProfile => {
943+ assert ( appProfile instanceof FakeAppProfile ) ;
944+ appProfiles . push ( appProfile ) ;
945+ } )
946+ . on ( 'end' , ( ) => {
947+ done ( ) ;
948+ } ) ;
949+ } ) ;
950+
870951 it ( 'should return an array of AppProfile objects' , done => {
871952 const response = [
872953 {
0 commit comments