@@ -3,7 +3,7 @@ import { ActionRequestMessage, handle } from './handler';
3
3
4
4
import { createAppAuth } from '@octokit/auth-app' ;
5
5
import { Octokit } from '@octokit/rest' ;
6
- import { listRunners } from './runners' ;
6
+ import { listRunners , createRunner } from './runners' ;
7
7
8
8
jest . mock ( '@octokit/auth-app' , ( ) => ( {
9
9
createAppAuth : jest . fn ( ) . mockImplementation ( ( ) => jest . fn ( ) . mockImplementation ( ( ) => ( { token : 'Blaat' } ) ) ) ,
@@ -37,6 +37,7 @@ describe('handler', () => {
37
37
process . env . GITHUB_APP_CLIENT_ID = 'TEST_CLIENT_ID' ;
38
38
process . env . GITHUB_APP_CLIENT_SECRET = 'TEST_CLIENT_SECRET' ;
39
39
process . env . RUNNERS_MAXIMUM_COUNT = '3' ;
40
+ process . env . ENVIRONMENT = 'unit-test-environment' ;
40
41
jest . clearAllMocks ( ) ;
41
42
mockOctokit . actions . listRepoWorkflowRuns . mockImplementation ( ( ) => ( {
42
43
data : {
@@ -106,6 +107,16 @@ describe('handler', () => {
106
107
org : TEST_DATA . repositoryOwner ,
107
108
} ) ;
108
109
} ) ;
110
+
111
+ it ( 'creates a runner with correct config' , async ( ) => {
112
+ await handle ( 'aws:sqs' , TEST_DATA ) ;
113
+ expect ( createRunner ) . toBeCalledWith ( {
114
+ environment : 'unit-test-environment' ,
115
+ runnerConfig : `--url https://github.com/${ TEST_DATA . repositoryOwner } --token 1234abcd` ,
116
+ orgName : TEST_DATA . repositoryOwner ,
117
+ repoName : undefined ,
118
+ } ) ;
119
+ } ) ;
109
120
} ) ;
110
121
111
122
describe ( 'on repo level' , ( ) => {
@@ -131,5 +142,15 @@ describe('handler', () => {
131
142
repo : TEST_DATA . repositoryName ,
132
143
} ) ;
133
144
} ) ;
145
+
146
+ it ( 'creates a runner with correct config' , async ( ) => {
147
+ await handle ( 'aws:sqs' , TEST_DATA ) ;
148
+ expect ( createRunner ) . toBeCalledWith ( {
149
+ environment : 'unit-test-environment' ,
150
+ runnerConfig : `--url https://github.com/${ TEST_DATA . repositoryOwner } /${ TEST_DATA . repositoryName } --token 1234abcd` ,
151
+ orgName : undefined ,
152
+ repoName : `${ TEST_DATA . repositoryOwner } /${ TEST_DATA . repositoryName } ` ,
153
+ } ) ;
154
+ } ) ;
134
155
} ) ;
135
156
} ) ;
0 commit comments