This repository was archived by the owner on Jan 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change 33 BuilderContext ,
44 BuilderRun ,
55 ScheduleOptions ,
6- Target
6+ Target ,
7+ BuilderOutput
78} from '@angular-devkit/architect/src/index' ;
89import deploy from './actions' ;
910
@@ -60,6 +61,25 @@ describe('Deploy Angular apps', () => {
6061 expect ( e . message ) . toMatch ( / C a n n o t e x e c u t e t h e b u i l d t a r g e t / ) ;
6162 }
6263 } ) ;
64+
65+ it ( 'throws if app building fails' , async ( ) => {
66+ context . scheduleTarget = (
67+ _ : Target ,
68+ __ ?: JsonObject ,
69+ ___ ?: ScheduleOptions
70+ ) =>
71+ Promise . resolve ( {
72+ result : Promise . resolve (
73+ createBuilderOutputMock ( false , 'build error test' )
74+ )
75+ } as BuilderRun ) ;
76+ try {
77+ await deploy ( mockEngine , context , 'host' , { } ) ;
78+ fail ( ) ;
79+ } catch ( e ) {
80+ expect ( e . message ) . toMatch ( / b u i l d e r r o r t e s t / ) ;
81+ }
82+ } ) ;
6383 } ) ;
6484} ) ;
6585
@@ -90,6 +110,20 @@ const initMocks = () => {
90110 scheduleBuilder : ( _ : string , __ ?: JsonObject , ___ ?: ScheduleOptions ) =>
91111 Promise . resolve ( { } as BuilderRun ) ,
92112 scheduleTarget : ( _ : Target , __ ?: JsonObject , ___ ?: ScheduleOptions ) =>
93- Promise . resolve ( { } as BuilderRun )
113+ Promise . resolve ( {
114+ result : Promise . resolve ( createBuilderOutputMock ( true , '' ) )
115+ } as BuilderRun )
116+ } ;
117+ } ;
118+
119+ const createBuilderOutputMock = (
120+ success : boolean ,
121+ error : string
122+ ) : BuilderOutput => {
123+ return {
124+ info : { info : null } ,
125+ error : error ,
126+ success : success ,
127+ target : { } as Target
94128 } ;
95129} ;
Original file line number Diff line number Diff line change @@ -46,7 +46,11 @@ export default async function deploy(
4646 } ,
4747 overrides as json . JsonObject
4848 ) ;
49- await build . result ;
49+ const buildResult = await build . result ;
50+
51+ if ( ! buildResult . success ) {
52+ throw new Error ( buildResult . error ) ;
53+ }
5054 }
5155
5256 await engine . run (
You can’t perform that action at this time.
0 commit comments