File tree 2 files changed +20
-0
lines changed
src/shared/infrastructure
tests/shared/unit/infrastructure
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ const createRelease = async function () {
35
35
url : lcmsConfig . url + '/releases' ,
36
36
headers : { Authorization : `Bearer ${ lcmsConfig . apiKey } ` } ,
37
37
} ) ;
38
+
39
+ if ( ! response . isSuccessful ) {
40
+ logger . error ( `An error occurred while creating a release on ${ lcmsConfig . url } : ${ JSON . stringify ( response ) } ` ) ;
41
+ throw new Error ( `An error occurred while creating a release on ${ lcmsConfig . url } ` ) ;
42
+ }
43
+
38
44
return response . data . content ;
39
45
} ;
40
46
Original file line number Diff line number Diff line change @@ -77,5 +77,19 @@ describe('Unit | Infrastructure | LCMS', function () {
77
77
// then
78
78
expect ( response ) . to . deep . equal ( learningContent ) ;
79
79
} ) ;
80
+
81
+ it ( 'throws when LCMS Api response is not successful' , async function ( ) {
82
+ // given
83
+ nock ( 'https://lcms-test.pix.fr/api' )
84
+ . post ( '/releases' )
85
+ . matchHeader ( 'Authorization' , 'Bearer test-api-key' )
86
+ . reply ( 403 ) ;
87
+
88
+ // when
89
+ const error = await catchErr ( lcms . createRelease ) ( ) ;
90
+
91
+ // then
92
+ expect ( error . message ) . to . deep . equal ( 'An error occurred while creating a release on https://lcms-test.pix.fr/api' ) ;
93
+ } ) ;
80
94
} ) ;
81
95
} ) ;
You can’t perform that action at this time.
0 commit comments