@@ -3,6 +3,10 @@ import listReleases from '../../test/resources/github-list-releases.json';
3
3
import listReleasesEmpty from '../../test/resources/github-list-releases-empty-assets.json' ;
4
4
import listReleasesNoLinux from '../../test/resources/github-list-releases-no-linux.json' ;
5
5
import listReleasesNoArm64 from '../../test/resources/github-list-releases-no-arm64.json' ;
6
+ import { S3 } from 'aws-sdk' ;
7
+ import axios from 'axios' ;
8
+ import { request } from 'http' ;
9
+ import { EventEmitter , PassThrough , Readable } from 'stream' ;
6
10
7
11
const mockOctokit = {
8
12
repos : {
@@ -13,9 +17,26 @@ jest.mock('@octokit/rest', () => ({
13
17
Octokit : jest . fn ( ) . mockImplementation ( ( ) => mockOctokit ) ,
14
18
} ) ) ;
15
19
20
+ // mock stream for Axios
21
+ const mockResponse = `{"data": 123}` ;
22
+ const mockStream = new PassThrough ( ) ;
23
+ mockStream . push ( mockResponse ) ;
24
+ mockStream . end ( ) ;
25
+
26
+ jest . mock ( 'axios' ) ;
27
+ const mockedAxios = axios as jest . Mocked < typeof axios > ;
28
+ mockedAxios . request . mockResolvedValue ( {
29
+ data : mockStream ,
30
+ } ) ;
31
+
16
32
const mockS3 = {
17
33
getObjectTagging : jest . fn ( ) ,
18
- upload : jest . fn ( ) ,
34
+ // upload: jest.fn(() => {
35
+ // promise: jest.fn();
36
+ // }),
37
+ upload : jest . fn ( ) . mockImplementation ( ( ) => {
38
+ return { promise : jest . fn ( ( ) => Promise . resolve ( ) ) } ;
39
+ } ) ,
19
40
} ;
20
41
jest . mock ( 'aws-sdk' , ( ) => ( {
21
42
S3 : jest . fn ( ) . mockImplementation ( ( ) => mockS3 ) ,
@@ -27,6 +48,8 @@ beforeEach(() => {
27
48
jest . clearAllMocks ( ) ;
28
49
} ) ;
29
50
51
+ jest . setTimeout ( 60 * 1000 ) ;
52
+
30
53
describe ( 'Synchronize action distribution.' , ( ) => {
31
54
beforeEach ( ( ) => {
32
55
process . env . S3_BUCKET_NAME = bucketName ;
@@ -190,8 +213,8 @@ describe('Synchronize action distribution.', () => {
190
213
Key : bucketObjectKey ,
191
214
} ) ;
192
215
expect ( mockS3 . upload ) . toBeCalledTimes ( 1 ) ;
193
- const s3JsonBody = mockS3 . upload . mock . calls [ 0 ] [ 0 ] ;
194
- expect ( s3JsonBody [ 'Tagging' ] ) . toEqual ( 'name=actions-runner-linux-x64-2.273.0.tar.gz' ) ;
216
+ // const s3JsonBody = mockS3.upload.mock.calls[0][0];
217
+ // expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.273.0.tar.gz');
195
218
} ) ;
196
219
197
220
it ( 'No tag in S3, distribution should update.' , async ( ) => {
0 commit comments