3
3
BuilderContext ,
4
4
BuilderRun ,
5
5
ScheduleOptions ,
6
- Target
6
+ Target ,
7
+ BuilderOutput
7
8
} from '@angular-devkit/architect/src/index' ;
8
9
9
10
import deploy from './actions' ;
@@ -145,6 +146,25 @@ describe('Deploy Angular apps', () => {
145
146
) ;
146
147
}
147
148
} ) ;
149
+
150
+ it ( 'throws if app building fails' , async ( ) => {
151
+ context . scheduleTarget = (
152
+ _ : Target ,
153
+ __ ?: JsonObject ,
154
+ ___ ?: ScheduleOptions
155
+ ) =>
156
+ Promise . resolve ( {
157
+ result : Promise . resolve (
158
+ createBuilderOutputMock ( false , 'build error test' )
159
+ )
160
+ } as BuilderRun ) ;
161
+ try {
162
+ await deploy ( mockEngine , context , getBuildTarget ( ) , { } ) ;
163
+ fail ( ) ;
164
+ } catch ( e ) {
165
+ expect ( e . message ) . toMatch ( / b u i l d e r r o r t e s t / ) ;
166
+ }
167
+ } ) ;
148
168
} ) ;
149
169
} ) ;
150
170
@@ -163,7 +183,9 @@ const initMocks = () => {
163
183
workspaceRoot : 'my/workspace/root' ,
164
184
logger : new logging . NullLogger ( ) as any ,
165
185
scheduleTarget : ( _ : Target , __ ?: JsonObject , ___ ?: ScheduleOptions ) =>
166
- Promise . resolve ( { } as BuilderRun ) ,
186
+ Promise . resolve ( {
187
+ result : Promise . resolve ( createBuilderOutputMock ( true , '' ) )
188
+ } as BuilderRun ) ,
167
189
getTargetOptions : ( t : Target ) =>
168
190
Promise . resolve ( {
169
191
project : `projects/${ t . project } /some-file.json` ,
@@ -173,6 +195,18 @@ const initMocks = () => {
173
195
} as unknown ) as BuilderContext ;
174
196
} ;
175
197
198
+ const createBuilderOutputMock = (
199
+ success : boolean ,
200
+ error : string
201
+ ) : BuilderOutput => {
202
+ return {
203
+ info : { info : null } ,
204
+ error : error ,
205
+ success : success ,
206
+ target : { } as Target
207
+ } ;
208
+ } ;
209
+
176
210
const getBuildTarget = ( ) : BuildTarget => ( {
177
211
name : `${ PROJECT } :build:production`
178
212
} ) ;
0 commit comments