@@ -3,7 +3,7 @@ import { ActionRequestMessage, handle } from './handler';
33
44import { createAppAuth } from '@octokit/auth-app' ;
55import { Octokit } from '@octokit/rest' ;
6- import { listRunners } from './runners' ;
6+ import { listRunners , createRunner } from './runners' ;
77
88jest . mock ( '@octokit/auth-app' , ( ) => ( {
99 createAppAuth : jest . fn ( ) . mockImplementation ( ( ) => jest . fn ( ) . mockImplementation ( ( ) => ( { token : 'Blaat' } ) ) ) ,
@@ -37,6 +37,7 @@ describe('handler', () => {
3737 process . env . GITHUB_APP_CLIENT_ID = 'TEST_CLIENT_ID' ;
3838 process . env . GITHUB_APP_CLIENT_SECRET = 'TEST_CLIENT_SECRET' ;
3939 process . env . RUNNERS_MAXIMUM_COUNT = '3' ;
40+ process . env . ENVIRONMENT = 'unit-test-environment' ;
4041 jest . clearAllMocks ( ) ;
4142 mockOctokit . actions . listRepoWorkflowRuns . mockImplementation ( ( ) => ( {
4243 data : {
@@ -106,6 +107,16 @@ describe('handler', () => {
106107 org : TEST_DATA . repositoryOwner ,
107108 } ) ;
108109 } ) ;
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+ } ) ;
109120 } ) ;
110121
111122 describe ( 'on repo level' , ( ) => {
@@ -131,5 +142,15 @@ describe('handler', () => {
131142 repo : TEST_DATA . repositoryName ,
132143 } ) ;
133144 } ) ;
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+ } ) ;
134155 } ) ;
135156} ) ;
0 commit comments