@@ -1115,8 +1115,9 @@ const stalledResponseBody = (status: number): Response =>
11151115 { status, headers : { "content-type" : "application/json" } } ,
11161116 ) ;
11171117
1118- for ( const status of [ 200 , 503 ] ) {
1119- it . effect ( `times out a stalled Bitbucket JSON body after HTTP ${ status } headers` , ( ) => {
1118+ it . effect . each ( [ 200 , 503 ] ) (
1119+ "times out a stalled Bitbucket JSON body after HTTP %s headers" ,
1120+ ( status ) => {
11201121 const { execute, layer } = makeLayer ( { response : ( ) => stalledResponseBody ( status ) } ) ;
11211122 return Effect . gen ( function * ( ) {
11221123 const api = yield * BitbucketApi . BitbucketApi ;
@@ -1129,9 +1130,12 @@ for (const status of [200, 503]) {
11291130 assert . instanceOf ( error , BitbucketApi . BitbucketRequestError ) ;
11301131 assert . strictEqual ( error . operation , "getPullRequest" ) ;
11311132 } ) . pipe ( Effect . provide ( layer ) ) ;
1132- } ) ;
1133+ } ,
1134+ ) ;
11331135
1134- it . effect ( `times out a stalled Bitbucket raw body after HTTP ${ status } headers` , ( ) => {
1136+ it . effect . each ( [ 200 , 503 ] ) (
1137+ "times out a stalled Bitbucket raw body after HTTP %s headers" ,
1138+ ( status ) => {
11351139 const { execute, layer } = makeLayer ( { response : ( ) => stalledResponseBody ( status ) } ) ;
11361140 return Effect . gen ( function * ( ) {
11371141 const api = yield * BitbucketApi . BitbucketApi ;
@@ -1144,26 +1148,35 @@ for (const status of [200, 503]) {
11441148 assert . instanceOf ( error , BitbucketApi . BitbucketRequestError ) ;
11451149 assert . strictEqual ( error . operation , "request" ) ;
11461150 } ) . pipe ( Effect . provide ( layer ) ) ;
1147- } ) ;
1148- }
1151+ } ,
1152+ ) ;
11491153
1150- for ( const kind of [ "json" , "raw" ] as const ) {
1151- it . effect ( `times out before headers for ${ kind } Bitbucket requests` , ( ) => {
1152- const { execute, layer } = makeLayer ( { response : ( ) => Response . json ( { } ) , stall : true } ) ;
1153- return Effect . gen ( function * ( ) {
1154- const api = yield * BitbucketApi . BitbucketApi ;
1155- const fiber = yield * Effect . forkChild (
1156- Effect . flip (
1157- kind === "json"
1158- ? api . getPullRequest ( { cwd : "/repo" , reference : "42" } )
1159- : api . request ( { method : "GET" , url : "/user" } ) ,
1160- ) ,
1161- ) ;
1162- while ( execute . mock . calls . length === 0 ) yield * Effect . yieldNow ;
1163- yield * TestClock . adjust ( "31 seconds" ) ;
1164- const error = yield * Fiber . join ( fiber ) ;
1165- assert . instanceOf ( error , BitbucketApi . BitbucketRequestError ) ;
1166- assert . strictEqual ( error . operation , kind === "json" ? "getPullRequest" : "request" ) ;
1167- } ) . pipe ( Effect . provide ( layer ) ) ;
1168- } ) ;
1169- }
1154+ it . effect ( "times out before JSON headers arrive" , ( ) => {
1155+ const { execute, layer } = makeLayer ( { response : ( ) => Response . json ( { } ) , stall : true } ) ;
1156+ return Effect . gen ( function * ( ) {
1157+ const api = yield * BitbucketApi . BitbucketApi ;
1158+ const fiber = yield * Effect . forkChild (
1159+ Effect . flip ( api . getPullRequest ( { cwd : "/repo" , reference : "42" } ) ) ,
1160+ ) ;
1161+ while ( execute . mock . calls . length === 0 ) yield * Effect . yieldNow ;
1162+ yield * TestClock . adjust ( "31 seconds" ) ;
1163+ const error = yield * Fiber . join ( fiber ) ;
1164+ assert . instanceOf ( error , BitbucketApi . BitbucketRequestError ) ;
1165+ assert . strictEqual ( error . operation , "getPullRequest" ) ;
1166+ } ) . pipe ( Effect . provide ( layer ) ) ;
1167+ } ) ;
1168+
1169+ it . effect ( "times out before raw response headers arrive" , ( ) => {
1170+ const { execute, layer } = makeLayer ( { response : ( ) => Response . json ( { } ) , stall : true } ) ;
1171+ return Effect . gen ( function * ( ) {
1172+ const api = yield * BitbucketApi . BitbucketApi ;
1173+ const fiber = yield * Effect . forkChild (
1174+ Effect . flip ( api . request ( { method : "GET" , url : "/user" } ) ) ,
1175+ ) ;
1176+ while ( execute . mock . calls . length === 0 ) yield * Effect . yieldNow ;
1177+ yield * TestClock . adjust ( "31 seconds" ) ;
1178+ const error = yield * Fiber . join ( fiber ) ;
1179+ assert . instanceOf ( error , BitbucketApi . BitbucketRequestError ) ;
1180+ assert . strictEqual ( error . operation , "request" ) ;
1181+ } ) . pipe ( Effect . provide ( layer ) ) ;
1182+ } ) ;
0 commit comments