-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: -d usage with -t different than HEAD (#159)
Co-authored-by: Mehdi Cherfaoui <[email protected]> Co-authored-by: Mehdi Cherfaoui <>
- Loading branch information
1 parent
9620574
commit 1a5ead0
Showing
6 changed files
with
154 additions
and
27 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 |
---|---|---|
@@ -1,25 +1,69 @@ | ||
'use strict' | ||
const repoSetup = require('../../../../src/utils/repoSetup') | ||
const RepoSetup = require('../../../../src/utils/repoSetup') | ||
const gc = require('../../../../src/utils/gitConstants') | ||
const child_process = require('child_process') | ||
jest.mock('child_process', () => ({ spawnSync: jest.fn() })) | ||
jest.mock('fs-extra') | ||
jest.mock('fs') | ||
|
||
describe(`test if repoSetup`, () => { | ||
test('say "to" equal "HEAD"', () => { | ||
const config = { repo: '.', to: 'HEAD' } | ||
child_process.spawnSync.mockImplementation(() => ({ | ||
stdout: '', | ||
})) | ||
const repoSetup = new RepoSetup(config) | ||
const toEqualHead = repoSetup.isToEqualHead() | ||
|
||
expect(toEqualHead).toBe(true) | ||
expect(child_process.spawnSync).not.toHaveBeenCalled() | ||
}) | ||
|
||
test('say when "to" do not equals "HEAD"', () => { | ||
const config = { repo: '.', to: 'not HEAD' } | ||
child_process.spawnSync | ||
.mockReturnValueOnce({ stdout: Buffer.from('HEAD', gc.UTF8_ENCODING) }) | ||
.mockReturnValueOnce({ | ||
stdout: Buffer.from('not HEAD', gc.UTF8_ENCODING), | ||
}) | ||
const repoSetup = new RepoSetup(config) | ||
const toEqualHead = repoSetup.isToEqualHead() | ||
|
||
expect(toEqualHead).toBe(false) | ||
expect(child_process.spawnSync).toHaveBeenCalled() | ||
}) | ||
|
||
test('can set config.from if not defined', () => { | ||
const config = { repo: '.' } | ||
child_process.spawnSync.mockImplementation(() => ({ | ||
stdout: '', | ||
})) | ||
repoSetup(config) | ||
expect(config.from).not.toBeUndefined() | ||
const repoSetup = new RepoSetup(config) | ||
const firsSha = repoSetup.computeFromRef() | ||
|
||
expect(firsSha).not.toBeUndefined() | ||
expect(child_process.spawnSync).toHaveBeenCalled() | ||
}) | ||
|
||
test('can set config.from if defined', () => { | ||
const config = { repo: '.', from: 'HEAD~1' } | ||
child_process.spawnSync.mockImplementation(() => ({ | ||
stdout: '', | ||
})) | ||
const repoSetup = new RepoSetup(config) | ||
const firsSha = repoSetup.computeFromRef() | ||
|
||
expect(firsSha).not.toBeUndefined() | ||
expect(child_process.spawnSync).not.toHaveBeenCalled() | ||
}) | ||
|
||
test('can set core.quotepath to off', () => { | ||
const config = { repo: '.', from: 'HEAD' } | ||
const config = { repo: '.', from: 'HEAD~1' } | ||
child_process.spawnSync.mockImplementation(() => ({ | ||
stdout: '', | ||
})) | ||
repoSetup(config) | ||
expect(config.from).not.toBeUndefined() | ||
const repoSetup = new RepoSetup(config) | ||
repoSetup.repoConfiguration() | ||
expect(child_process.spawnSync).toHaveBeenCalled() | ||
}) | ||
}) |
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