11import { mocked } from 'ts-jest/utils' ;
2- import { ActionRequestMessage , handle } from './handler ' ;
2+ import { ActionRequestMessage , scaleUp } from './scale-up ' ;
33
44import { createAppAuth } from '@octokit/auth-app' ;
55import { Octokit } from '@octokit/rest' ;
@@ -30,7 +30,7 @@ const TEST_DATA: ActionRequestMessage = {
3030 installationId : 2 ,
3131} ;
3232
33- describe ( 'handler ' , ( ) => {
33+ describe ( 'scaleUp ' , ( ) => {
3434 beforeEach ( ( ) => {
3535 process . env . GITHUB_APP_KEY_BASE64 = 'TEST_CERTIFICATE_DATA' ;
3636 process . env . GITHUB_APP_ID = '1337' ;
@@ -64,11 +64,11 @@ describe('handler', () => {
6464
6565 it ( 'ignores non-sqs events' , async ( ) => {
6666 expect . assertions ( 1 ) ;
67- expect ( handle ( 'aws:s3' , TEST_DATA ) ) . rejects . toEqual ( Error ( 'Cannot handle non-SQS events!' ) ) ;
67+ expect ( scaleUp ( 'aws:s3' , TEST_DATA ) ) . rejects . toEqual ( Error ( 'Cannot handle non-SQS events!' ) ) ;
6868 } ) ;
6969
7070 it ( 'checks queued workflows' , async ( ) => {
71- await handle ( 'aws:sqs' , TEST_DATA ) ;
71+ await scaleUp ( 'aws:sqs' , TEST_DATA ) ;
7272 expect ( mockOctokit . actions . listRepoWorkflowRuns ) . toBeCalledWith ( {
7373 owner : TEST_DATA . repositoryOwner ,
7474 repo : TEST_DATA . repositoryName ,
@@ -80,7 +80,7 @@ describe('handler', () => {
8080 mockOctokit . actions . listRepoWorkflowRuns . mockImplementation ( ( ) => ( {
8181 data : { total_count : 0 , runners : [ ] } ,
8282 } ) ) ;
83- await handle ( 'aws:sqs' , TEST_DATA ) ;
83+ await scaleUp ( 'aws:sqs' , TEST_DATA ) ;
8484 expect ( listRunners ) . not . toBeCalled ( ) ;
8585 } ) ;
8686
@@ -90,7 +90,7 @@ describe('handler', () => {
9090 } ) ;
9191
9292 it ( 'gets the current org level runners' , async ( ) => {
93- await handle ( 'aws:sqs' , TEST_DATA ) ;
93+ await scaleUp ( 'aws:sqs' , TEST_DATA ) ;
9494 expect ( listRunners ) . toBeCalledWith ( {
9595 environment : 'unit-test-environment' ,
9696 repoName : undefined ,
@@ -99,20 +99,20 @@ describe('handler', () => {
9999
100100 it ( 'does not create a token when maximum runners has been reached' , async ( ) => {
101101 process . env . RUNNERS_MAXIMUM_COUNT = '1' ;
102- await handle ( 'aws:sqs' , TEST_DATA ) ;
102+ await scaleUp ( 'aws:sqs' , TEST_DATA ) ;
103103 expect ( mockOctokit . actions . createRegistrationTokenForOrg ) . not . toBeCalled ( ) ;
104104 } ) ;
105105
106106 it ( 'creates a token when maximum runners has not been reached' , async ( ) => {
107- await handle ( 'aws:sqs' , TEST_DATA ) ;
107+ await scaleUp ( 'aws:sqs' , TEST_DATA ) ;
108108 expect ( mockOctokit . actions . createRegistrationTokenForOrg ) . toBeCalled ( ) ;
109109 expect ( mockOctokit . actions . createRegistrationTokenForOrg ) . toBeCalledWith ( {
110110 org : TEST_DATA . repositoryOwner ,
111111 } ) ;
112112 } ) ;
113113
114114 it ( 'creates a runner with correct config' , async ( ) => {
115- await handle ( 'aws:sqs' , TEST_DATA ) ;
115+ await scaleUp ( 'aws:sqs' , TEST_DATA ) ;
116116 expect ( createRunner ) . toBeCalledWith ( {
117117 environment : 'unit-test-environment' ,
118118 runnerConfig : `--url https://github.com/${ TEST_DATA . repositoryOwner } --token 1234abcd` ,
@@ -128,7 +128,7 @@ describe('handler', () => {
128128 } ) ;
129129
130130 it ( 'gets the current repo level runners' , async ( ) => {
131- await handle ( 'aws:sqs' , TEST_DATA ) ;
131+ await scaleUp ( 'aws:sqs' , TEST_DATA ) ;
132132 expect ( listRunners ) . toBeCalledWith ( {
133133 environment : 'unit-test-environment' ,
134134 repoName : `${ TEST_DATA . repositoryOwner } /${ TEST_DATA . repositoryName } ` ,
@@ -137,20 +137,20 @@ describe('handler', () => {
137137
138138 it ( 'does not create a token when maximum runners has been reached' , async ( ) => {
139139 process . env . RUNNERS_MAXIMUM_COUNT = '1' ;
140- await handle ( 'aws:sqs' , TEST_DATA ) ;
140+ await scaleUp ( 'aws:sqs' , TEST_DATA ) ;
141141 expect ( mockOctokit . actions . createRegistrationTokenForRepo ) . not . toBeCalled ( ) ;
142142 } ) ;
143143
144144 it ( 'creates a token when maximum runners has not been reached' , async ( ) => {
145- await handle ( 'aws:sqs' , TEST_DATA ) ;
145+ await scaleUp ( 'aws:sqs' , TEST_DATA ) ;
146146 expect ( mockOctokit . actions . createRegistrationTokenForRepo ) . toBeCalledWith ( {
147147 owner : TEST_DATA . repositoryOwner ,
148148 repo : TEST_DATA . repositoryName ,
149149 } ) ;
150150 } ) ;
151151
152152 it ( 'creates a runner with correct config' , async ( ) => {
153- await handle ( 'aws:sqs' , TEST_DATA ) ;
153+ await scaleUp ( 'aws:sqs' , TEST_DATA ) ;
154154 expect ( createRunner ) . toBeCalledWith ( {
155155 environment : 'unit-test-environment' ,
156156 runnerConfig : `--url https://github.com/${ TEST_DATA . repositoryOwner } /${ TEST_DATA . repositoryName } --token 1234abcd` ,
0 commit comments