@@ -4,7 +4,7 @@ import {getRetryOptions} from '../src/retry-options'
4
4
5
5
describe ( 'getRequestOptions' , ( ) => {
6
6
test ( 'retries disabled if retries == 0' , async ( ) => {
7
- const [ retryOptions , requestOptions ] = getRetryOptions (
7
+ const [ retryOptions , requestOptions , throttlingOptions ] = getRetryOptions (
8
8
0 ,
9
9
[ 400 , 500 , 502 ] ,
10
10
[ ]
@@ -14,10 +14,12 @@ describe('getRequestOptions', () => {
14
14
expect ( retryOptions . doNotRetry ) . toBeFalsy ( )
15
15
16
16
expect ( requestOptions ?. retries ) . toBeFalsy ( )
17
+ expect ( throttlingOptions ?. onRateLimit ) . toBeFalsy ( )
18
+ expect ( throttlingOptions ?. onSecondaryRateLimit ) . toBeFalsy ( )
17
19
} )
18
20
19
21
test ( 'properties set if retries > 0' , async ( ) => {
20
- const [ retryOptions , requestOptions ] = getRetryOptions (
22
+ const [ retryOptions , requestOptions , throttlingOptions ] = getRetryOptions (
21
23
1 ,
22
24
[ 400 , 500 , 502 ] ,
23
25
[ ]
@@ -27,10 +29,12 @@ describe('getRequestOptions', () => {
27
29
expect ( retryOptions . doNotRetry ) . toEqual ( [ 400 , 500 , 502 ] )
28
30
29
31
expect ( requestOptions ?. retries ) . toEqual ( 1 )
32
+ expect ( throttlingOptions ?. onRateLimit ) . toBeDefined ( )
33
+ expect ( throttlingOptions ?. onSecondaryRateLimit ) . toBeDefined ( )
30
34
} )
31
35
32
36
test ( 'properties set if retries > 0' , async ( ) => {
33
- const [ retryOptions , requestOptions ] = getRetryOptions (
37
+ const [ retryOptions , requestOptions , throttlingOptions ] = getRetryOptions (
34
38
1 ,
35
39
[ 400 , 500 , 502 ] ,
36
40
[ ]
@@ -40,30 +44,45 @@ describe('getRequestOptions', () => {
40
44
expect ( retryOptions . doNotRetry ) . toEqual ( [ 400 , 500 , 502 ] )
41
45
42
46
expect ( requestOptions ?. retries ) . toEqual ( 1 )
47
+ expect ( throttlingOptions ?. onRateLimit ) . toBeDefined ( )
48
+ expect ( throttlingOptions ?. onSecondaryRateLimit ) . toBeDefined ( )
43
49
} )
44
50
45
51
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
+ )
47
57
48
58
expect ( retryOptions . enabled ) . toBe ( true )
49
59
expect ( retryOptions . doNotRetry ) . toBeUndefined ( )
50
60
51
61
expect ( requestOptions ?. retries ) . toEqual ( 1 )
62
+ expect ( throttlingOptions ?. onRateLimit ) . toBeDefined ( )
63
+ expect ( throttlingOptions ?. onSecondaryRateLimit ) . toBeDefined ( )
52
64
} )
53
65
54
66
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
+ )
61
77
62
78
expect ( retryOptions . enabled ) . toBe ( true )
63
79
expect ( retryOptions . doNotRetry ) . toBeUndefined ( )
64
80
65
81
expect ( requestOptions ?. retries ) . toEqual ( 1 )
66
82
expect ( requestOptions ?. agent ) . toEqual ( 'default-user-agent' )
67
83
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 ( )
68
87
} )
69
88
} )
0 commit comments