@@ -4,7 +4,7 @@ import {getRetryOptions} from '../src/retry-options'
44
55describe ( 'getRequestOptions' , ( ) => {
66 test ( 'retries disabled if retries == 0' , async ( ) => {
7- const [ retryOptions , requestOptions ] = getRetryOptions (
7+ const [ retryOptions , requestOptions , throttlingOptions ] = getRetryOptions (
88 0 ,
99 [ 400 , 500 , 502 ] ,
1010 [ ]
@@ -14,10 +14,12 @@ describe('getRequestOptions', () => {
1414 expect ( retryOptions . doNotRetry ) . toBeFalsy ( )
1515
1616 expect ( requestOptions ?. retries ) . toBeFalsy ( )
17+ expect ( throttlingOptions ?. onRateLimit ) . toBeFalsy ( )
18+ expect ( throttlingOptions ?. onSecondaryRateLimit ) . toBeFalsy ( )
1719 } )
1820
1921 test ( 'properties set if retries > 0' , async ( ) => {
20- const [ retryOptions , requestOptions ] = getRetryOptions (
22+ const [ retryOptions , requestOptions , throttlingOptions ] = getRetryOptions (
2123 1 ,
2224 [ 400 , 500 , 502 ] ,
2325 [ ]
@@ -27,10 +29,12 @@ describe('getRequestOptions', () => {
2729 expect ( retryOptions . doNotRetry ) . toEqual ( [ 400 , 500 , 502 ] )
2830
2931 expect ( requestOptions ?. retries ) . toEqual ( 1 )
32+ expect ( throttlingOptions ?. onRateLimit ) . toBeDefined ( )
33+ expect ( throttlingOptions ?. onSecondaryRateLimit ) . toBeDefined ( )
3034 } )
3135
3236 test ( 'properties set if retries > 0' , async ( ) => {
33- const [ retryOptions , requestOptions ] = getRetryOptions (
37+ const [ retryOptions , requestOptions , throttlingOptions ] = getRetryOptions (
3438 1 ,
3539 [ 400 , 500 , 502 ] ,
3640 [ ]
@@ -40,30 +44,45 @@ describe('getRequestOptions', () => {
4044 expect ( retryOptions . doNotRetry ) . toEqual ( [ 400 , 500 , 502 ] )
4145
4246 expect ( requestOptions ?. retries ) . toEqual ( 1 )
47+ expect ( throttlingOptions ?. onRateLimit ) . toBeDefined ( )
48+ expect ( throttlingOptions ?. onSecondaryRateLimit ) . toBeDefined ( )
4349 } )
4450
4551 test ( 'retryOptions.doNotRetry not set if exemptStatusCodes isEmpty' , async ( ) => {
46- const [ retryOptions , requestOptions ] = getRetryOptions ( 1 , [ ] , [ ] )
52+ const [ retryOptions , requestOptions , throttlingOptions ] = getRetryOptions (
53+ 1 ,
54+ [ ] ,
55+ [ ]
56+ )
4757
4858 expect ( retryOptions . enabled ) . toBe ( true )
4959 expect ( retryOptions . doNotRetry ) . toBeUndefined ( )
5060
5161 expect ( requestOptions ?. retries ) . toEqual ( 1 )
62+ expect ( throttlingOptions ?. onRateLimit ) . toBeDefined ( )
63+ expect ( throttlingOptions ?. onSecondaryRateLimit ) . toBeDefined ( )
5264 } )
5365
5466 test ( 'requestOptions does not override defaults from @actions/github' , async ( ) => {
55- const [ retryOptions , requestOptions ] = getRetryOptions ( 1 , [ ] , {
56- request : {
57- agent : 'default-user-agent'
58- } ,
59- foo : 'bar'
60- } )
67+ const [ retryOptions , requestOptions , throttlingOptions ] = getRetryOptions (
68+ 1 ,
69+ [ ] ,
70+ {
71+ request : {
72+ agent : 'default-user-agent'
73+ } ,
74+ foo : 'bar'
75+ }
76+ )
6177
6278 expect ( retryOptions . enabled ) . toBe ( true )
6379 expect ( retryOptions . doNotRetry ) . toBeUndefined ( )
6480
6581 expect ( requestOptions ?. retries ) . toEqual ( 1 )
6682 expect ( requestOptions ?. agent ) . toEqual ( 'default-user-agent' )
6783 expect ( requestOptions ?. foo ) . toBeUndefined ( ) // this should not be in the `options.request` object, but at the same level as `request`
84+
85+ expect ( throttlingOptions ?. onRateLimit ) . toBeDefined ( )
86+ expect ( throttlingOptions ?. onSecondaryRateLimit ) . toBeDefined ( )
6887 } )
6988} )
0 commit comments