Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
- Loading branch information
1 parent
198b2fd
commit 93052ec
Showing
17 changed files
with
434 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import * as platform from './index'; | ||
|
||
describe('modules/platform/local/index', () => { | ||
describe('initPlatform', () => { | ||
it('returns input', async () => { | ||
expect(await platform.initPlatform({})).toMatchInlineSnapshot(` | ||
{ | ||
"dryRun": "lookup", | ||
"endpoint": "local", | ||
"persistRepoData": true, | ||
"requireConfig": "optional", | ||
} | ||
`); | ||
}); | ||
}); | ||
|
||
describe('getRepos', () => { | ||
it('returns empty array', async () => { | ||
expect(await platform.getRepos()).toEqual([]); | ||
}); | ||
}); | ||
|
||
describe('initRepo', () => { | ||
it('returns object', async () => { | ||
expect(await platform.initRepo()).toMatchInlineSnapshot(` | ||
{ | ||
"defaultBranch": "", | ||
"isFork": false, | ||
"repoFingerprint": "", | ||
} | ||
`); | ||
}); | ||
}); | ||
|
||
describe('dummy functions', () => { | ||
it('getRepoForceRebase', async () => { | ||
expect(await platform.getRepoForceRebase()).toBe(false); | ||
}); | ||
|
||
it('findIssue', async () => { | ||
expect(await platform.findIssue()).toBeNull(); | ||
}); | ||
|
||
it('getIssueList', async () => { | ||
expect(await platform.getIssueList()).toEqual([]); | ||
}); | ||
|
||
it('getRawFile', async () => { | ||
expect(await platform.getRawFile()).toBeNull(); | ||
}); | ||
|
||
it('getJsonFile', async () => { | ||
expect(await platform.getJsonFile()).toBeNull(); | ||
}); | ||
|
||
it('getPrList', async () => { | ||
expect(await platform.getPrList()).toEqual([]); | ||
}); | ||
|
||
it('ensureIssueClosing', async () => { | ||
expect(await platform.ensureIssueClosing()).toBeUndefined(); | ||
}); | ||
|
||
it('ensureIssue', async () => { | ||
expect(await platform.ensureIssue()).toBeNull(); | ||
}); | ||
|
||
it('massageMarkdown', () => { | ||
expect(platform.massageMarkdown('foo')).toBe('foo'); | ||
}); | ||
|
||
it('updatePr', async () => { | ||
expect(await platform.updatePr()).toBeUndefined(); | ||
}); | ||
|
||
it('mergePr', async () => { | ||
expect(await platform.mergePr()).toBe(false); | ||
}); | ||
|
||
it('addReviewers', async () => { | ||
expect(await platform.addReviewers()).toBeUndefined(); | ||
}); | ||
|
||
it('addAssignees', async () => { | ||
expect(await platform.addAssignees()).toBeUndefined(); | ||
}); | ||
|
||
it('createPr', async () => { | ||
expect(await platform.createPr()).toBeNull(); | ||
}); | ||
|
||
it('deleteLabel', async () => { | ||
expect(await platform.deleteLabel()).toBeUndefined(); | ||
}); | ||
|
||
it('setBranchStatus', async () => { | ||
expect(await platform.setBranchStatus()).toBeUndefined(); | ||
}); | ||
|
||
it('getBranchStatus', async () => { | ||
expect(await platform.getBranchStatus()).toBe('red'); | ||
}); | ||
|
||
it('getBranchStatusCheck', async () => { | ||
expect(await platform.getBranchStatusCheck()).toBeNull(); | ||
}); | ||
|
||
it('ensureCommentRemoval', async () => { | ||
expect(await platform.ensureCommentRemoval()).toBeUndefined(); | ||
}); | ||
|
||
it('ensureComment', async () => { | ||
expect(await platform.ensureComment()).toBeFalse(); | ||
}); | ||
|
||
it('getPr', async () => { | ||
expect(await platform.getPr()).toBeNull(); | ||
}); | ||
|
||
it('findPr', async () => { | ||
expect(await platform.findPr()).toBeNull(); | ||
}); | ||
|
||
it('getBranchPr', async () => { | ||
expect(await platform.getBranchPr()).toBeNull(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import type { BranchStatus } from '../../../types'; | ||
import type { | ||
Issue, | ||
PlatformParams, | ||
PlatformResult, | ||
Pr, | ||
RepoResult, | ||
} from '../types'; | ||
|
||
export const id = 'local'; | ||
|
||
export function initPlatform(params: PlatformParams): Promise<PlatformResult> { | ||
return Promise.resolve({ | ||
dryRun: 'lookup', | ||
endpoint: 'local', | ||
persistRepoData: true, | ||
requireConfig: 'optional', | ||
}); | ||
} | ||
|
||
export function getRepos(): Promise<string[]> { | ||
return Promise.resolve([]); | ||
} | ||
|
||
export function initRepo(): Promise<RepoResult> { | ||
return Promise.resolve({ | ||
defaultBranch: '', | ||
isFork: false, | ||
repoFingerprint: '', | ||
}); | ||
} | ||
|
||
export function getRepoForceRebase(): Promise<boolean> { | ||
return Promise.resolve(false); | ||
} | ||
|
||
export function findIssue(): Promise<null> { | ||
return Promise.resolve(null); | ||
} | ||
|
||
export function getIssueList(): Promise<Issue[]> { | ||
return Promise.resolve([]); | ||
} | ||
|
||
export function getRawFile(): Promise<string | null> { | ||
return Promise.resolve(null); | ||
} | ||
|
||
export function getJsonFile(): Promise<Record<string, unknown> | null> { | ||
return Promise.resolve(null); | ||
} | ||
|
||
export function getPrList(): Promise<Pr[]> { | ||
return Promise.resolve([]); | ||
} | ||
|
||
export function ensureIssueClosing(): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
export function ensureIssue(): Promise<null> { | ||
return Promise.resolve(null); | ||
} | ||
|
||
export function massageMarkdown(input: string): string { | ||
return input; | ||
} | ||
|
||
export function updatePr(): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
export function mergePr(): Promise<boolean> { | ||
return Promise.resolve(false); | ||
} | ||
|
||
export function addReviewers(): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
export function addAssignees(): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
export function createPr(): Promise<null> { | ||
return Promise.resolve(null); | ||
} | ||
|
||
export function deleteLabel(): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
export function setBranchStatus(): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
export function getBranchStatus(): Promise<BranchStatus> { | ||
return Promise.resolve('red'); | ||
} | ||
|
||
export function getBranchStatusCheck(): Promise<null> { | ||
return Promise.resolve(null); | ||
} | ||
|
||
export function ensureCommentRemoval(): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
export function ensureComment(): Promise<boolean> { | ||
return Promise.resolve(false); | ||
} | ||
|
||
export function getPr(): Promise<null> { | ||
return Promise.resolve(null); | ||
} | ||
|
||
export function findPr(): Promise<null> { | ||
return Promise.resolve(null); | ||
} | ||
|
||
export function getBranchPr(): Promise<null> { | ||
return Promise.resolve(null); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { execSync as _execSync } from 'node:child_process'; | ||
import { mockedFunction } from '../../../../test/util'; | ||
import { LocalFs } from './scm'; | ||
|
||
jest.mock('node:child_process'); | ||
const execSync = mockedFunction(_execSync); | ||
|
||
describe('modules/platform/local/scm', () => { | ||
let localFs: LocalFs; | ||
|
||
beforeEach(() => { | ||
localFs = new LocalFs(); | ||
}); | ||
|
||
describe('dummy functions', () => { | ||
it('behindBaseBranch', async () => { | ||
expect(await localFs.isBranchBehindBase('', '')).toBe(false); | ||
}); | ||
|
||
it('isBranchModified', async () => { | ||
expect(await localFs.isBranchModified('')).toBe(false); | ||
}); | ||
|
||
it('isBranchConflicted', async () => { | ||
expect(await localFs.isBranchConflicted('', '')).toBe(false); | ||
}); | ||
|
||
it('branchExists', async () => { | ||
expect(await localFs.branchExists('')).toBe(true); | ||
}); | ||
|
||
it('getBranchCommit', async () => { | ||
expect(await localFs.getBranchCommit('')).toBeNull(); | ||
}); | ||
|
||
it('deleteBranch', async () => { | ||
expect(await localFs.deleteBranch('')).toBeUndefined(); | ||
}); | ||
|
||
it('commitAndPush', async () => { | ||
expect(await localFs.commitAndPush({} as any)).toBeNull(); | ||
}); | ||
|
||
it('checkoutBranch', async () => { | ||
expect(await localFs.checkoutBranch('')).toBe(''); | ||
}); | ||
}); | ||
|
||
describe('getFileList', () => { | ||
it('should return file list using git', async () => { | ||
execSync.mockReturnValueOnce('file1\nfile2'); | ||
expect(await localFs.getFileList()).toHaveLength(2); | ||
}); | ||
|
||
it('should return file list using glob', async () => { | ||
execSync.mockImplementationOnce(() => { | ||
throw new Error(); | ||
}); | ||
jest.mock('glob', () => ({ | ||
glob: jest | ||
.fn() | ||
.mockImplementation(() => Promise.resolve(['file1', 'file2'])), | ||
})); | ||
|
||
expect(await localFs.getFileList()).toHaveLength(2); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.