File tree 2 files changed +5
-13
lines changed
2 files changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -130,18 +130,12 @@ describe('printActionsRuntimeTokenACs', () => {
130
130
process . env = originalEnv ;
131
131
} ) ;
132
132
it ( 'empty' , async ( ) => {
133
- const warnSpy = jest . spyOn ( core , 'warning' ) ;
134
133
process . env . ACTIONS_RUNTIME_TOKEN = '' ;
135
- await GitHub . printActionsRuntimeTokenACs ( ) ;
136
- expect ( warnSpy ) . toHaveBeenCalledTimes ( 1 ) ;
137
- expect ( warnSpy ) . toHaveBeenCalledWith ( `ACTIONS_RUNTIME_TOKEN not set` ) ;
134
+ await expect ( GitHub . printActionsRuntimeTokenACs ( ) ) . rejects . toThrowError ( new Error ( 'ACTIONS_RUNTIME_TOKEN not set' ) ) ;
138
135
} ) ;
139
136
it ( 'malformed' , async ( ) => {
140
- const warnSpy = jest . spyOn ( core , 'warning' ) ;
141
137
process . env . ACTIONS_RUNTIME_TOKEN = 'foo' ;
142
- await GitHub . printActionsRuntimeTokenACs ( ) ;
143
- expect ( warnSpy ) . toHaveBeenCalledTimes ( 1 ) ;
144
- expect ( warnSpy ) . toHaveBeenCalledWith ( `Cannot parse Actions Runtime Token: Invalid token specified: Cannot read properties of undefined (reading 'replace')` ) ;
138
+ await expect ( GitHub . printActionsRuntimeTokenACs ( ) ) . rejects . toThrowError ( new Error ( "Cannot parse GitHub Actions Runtime Token: Invalid token specified: Cannot read properties of undefined (reading 'replace')" ) ) ;
145
139
} ) ;
146
140
it ( 'refs/heads/master' , async ( ) => {
147
141
const infoSpy = jest . spyOn ( core , 'info' ) ;
Original file line number Diff line number Diff line change @@ -59,12 +59,10 @@ export class GitHub {
59
59
try {
60
60
jwt = GitHub . actionsRuntimeToken ;
61
61
} catch ( e ) {
62
- core . warning ( `Cannot parse Actions Runtime Token: ${ e . message } ` ) ;
63
- return ;
62
+ throw new Error ( `Cannot parse GitHub Actions Runtime Token: ${ e . message } ` ) ;
64
63
}
65
64
if ( ! jwt ) {
66
- core . warning ( `ACTIONS_RUNTIME_TOKEN not set` ) ;
67
- return ;
65
+ throw new Error ( `ACTIONS_RUNTIME_TOKEN not set` ) ;
68
66
}
69
67
try {
70
68
< Array < GitHubActionsRuntimeTokenAC > > JSON . parse ( `${ jwt . ac } ` ) . forEach ( ac => {
@@ -85,7 +83,7 @@ export class GitHub {
85
83
core . info ( `${ ac . Scope } : ${ permission } ` ) ;
86
84
} ) ;
87
85
} catch ( e ) {
88
- core . warning ( `Cannot parse Actions Runtime Token Access Controls : ${ e . message } ` ) ;
86
+ throw new Error ( `Cannot parse GitHub Actions Runtime Token ACs : ${ e . message } ` ) ;
89
87
}
90
88
}
91
89
}
You can’t perform that action at this time.
0 commit comments