mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-02-05 08:59:09 +08:00
make logging of git diff unconditional, remove parameter
This commit is contained in:
@@ -100,32 +100,26 @@ describe('Versioning', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('logDiffIfDirty', () => {
|
||||
it('does not throw', () => {
|
||||
expect(() => Versioning.logDiffIfDirty).not.toThrow();
|
||||
});
|
||||
|
||||
it('returns false by default', () => {
|
||||
expect(Versioning.logDiffIfDirty).toStrictEqual(false);
|
||||
});
|
||||
|
||||
it('does not call git diff if logDiffIfDirty is false', async () => {
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
const gitSpy = jest.spyOn(Versioning, 'git').mockReturnValue('');
|
||||
await Versioning.isDirty();
|
||||
expect(gitSpy).toHaveBeenCalledTimes(1);
|
||||
expect(gitSpy).toBeCalledWith(['status', '--porcelain']);
|
||||
});
|
||||
|
||||
it('calls git diff if logDiffIfDirty is true', async () => {
|
||||
describe('logging git diff', () => {
|
||||
it('calls git diff', async () => {
|
||||
// allowDirtyBuild: true
|
||||
jest.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
jest.spyOn(Versioning, 'isDirty').mockResolvedValue(false);
|
||||
jest.spyOn(Versioning, 'fetch').mockResolvedValue(undefined);
|
||||
jest.spyOn(Versioning, 'hasAnyVersionTags').mockResolvedValue(true);
|
||||
jest
|
||||
.spyOn(Versioning, 'parseSemanticVersion')
|
||||
.mockResolvedValue({ tag: 'mocktag', commits: 'abcdef', hash: '75822BCAF' });
|
||||
const logDiffSpy = jest.spyOn(Versioning, 'logDiff');
|
||||
const gitSpy = jest
|
||||
.spyOn(Versioning, 'git')
|
||||
.mockReturnValue('There is a diff actually! \n M My_Dirty_File.txt');
|
||||
await Versioning.isDirty();
|
||||
expect(gitSpy).toHaveBeenCalledTimes(2);
|
||||
expect(Versioning.git.mock.calls[0][0].indexOf('status')).toBeGreaterThan(-1);
|
||||
expect(Versioning.git.mock.calls[1][0].indexOf('diff')).toBeGreaterThan(-1);
|
||||
|
||||
await Versioning.generateSemanticVersion();
|
||||
|
||||
expect(logDiffSpy).toHaveBeenCalledTimes(1);
|
||||
expect(gitSpy).toHaveBeenCalledTimes(1);
|
||||
expect(Versioning.git.mock.calls[0][0].indexOf('diff')).toBeGreaterThan(-1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user