File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 1
1
import { gitAuthor } from '../../../config/release.config.json' ;
2
+ import * as common from '../../common' ;
2
3
import {
3
4
parseCommit ,
4
5
getVersionChangesText ,
@@ -25,7 +26,22 @@ const buildTestCommit = (
25
26
26
27
describe ( 'createReleasePR' , ( ) => {
27
28
beforeAll ( ( ) => {
28
- process . env . GITHUB_TOKEN = 'mocked' ;
29
+ // Mock `getOctokit` to bypass the API call and credential requirements
30
+ jest . spyOn ( common , 'getOctokit' ) . mockImplementation ( ( ) : any => {
31
+ return {
32
+ search : {
33
+ users : ( ) : any => ( {
34
+ data : {
35
+ total_count : 0 ,
36
+ } ,
37
+ } ) ,
38
+ } ,
39
+ } ;
40
+ } ) ;
41
+ } ) ;
42
+
43
+ afterAll ( ( ) => {
44
+ jest . spyOn ( common , 'getOctokit' ) . mockRestore ( ) ;
29
45
} ) ;
30
46
31
47
it ( 'reads versions of the current language' , ( ) => {
Original file line number Diff line number Diff line change @@ -2,10 +2,6 @@ import { getNextVersion } from '../createReleasePR';
2
2
import { getVersionsToRelease } from '../updateAPIVersions' ;
3
3
4
4
describe ( 'updateAPIversions' , ( ) => {
5
- beforeAll ( ( ) => {
6
- process . env . GITHUB_TOKEN = 'mocked' ;
7
- } ) ;
8
-
9
5
it ( 'gets versions to release' , ( ) => {
10
6
const versions = getVersionsToRelease ( {
11
7
javascript : {
Original file line number Diff line number Diff line change @@ -35,7 +35,6 @@ import { updateAPIVersions } from './updateAPIVersions';
35
35
dotenv . config ( { path : ROOT_ENV_PATH } ) ;
36
36
37
37
export const COMMON_SCOPES = [ 'specs' , 'clients' ] ;
38
- const octokit = getOctokit ( ) ;
39
38
40
39
// Prevent fetching the same user multiple times
41
40
const fetchedUsers : Record < string , string > = { } ;
@@ -148,6 +147,7 @@ export async function parseCommit(commit: string): Promise<Commit> {
148
147
149
148
// Retrieve the author GitHub username if publicly available
150
149
if ( ! fetchedUsers [ authorEmail ] ) {
150
+ const octokit = getOctokit ( ) ;
151
151
const { data } = await octokit . search . users ( {
152
152
q : authorEmail ,
153
153
} ) ;
@@ -465,6 +465,7 @@ async function createReleasePR(): Promise<void> {
465
465
await run ( `git checkout ${ MAIN_BRANCH } ` , { verbose : true } ) ;
466
466
467
467
console . log ( 'Creating prepare release pull request...' ) ;
468
+ const octokit = getOctokit ( ) ;
468
469
const { data } = await octokit . pulls . create ( {
469
470
owner : OWNER ,
470
471
repo : REPO ,
You can’t perform that action at this time.
0 commit comments