move checking of git checkout out of parse logic

This commit is contained in:
Conor Sloan
2024-04-15 15:43:26 +01:00
parent 881fd1c540
commit 18cf56a126
6 changed files with 31 additions and 14 deletions
+9 -3
View File
@@ -249,19 +249,25 @@ describe('ensureCorrectShaCheckedOut', () => {
it('does not throw an error if the correct SHA is checked out', async () => {
await expect(
fsHelper.ensureCorrectShaCheckedOut(`refs/tags/${tag2}`, commit2, dir)
fsHelper.ensureTagAndRefCheckedOut(`refs/tags/${tag2}`, commit2, dir)
).resolves.toBeUndefined()
})
it('throws an error if the correct SHA is not checked out', async () => {
await expect(
fsHelper.ensureCorrectShaCheckedOut(`refs/tags/${tag1}`, commit1, dir)
fsHelper.ensureTagAndRefCheckedOut(`refs/tags/${tag1}`, commit1, dir)
).rejects.toThrow()
})
it('throws an error if the sha of the tag does not match expected sha', async () => {
await expect(async () =>
fsHelper.ensureCorrectShaCheckedOut(`refs/tags/${tag1}`, commit2, dir)
fsHelper.ensureTagAndRefCheckedOut(`refs/tags/${tag1}`, commit2, dir)
).rejects.toThrow()
})
it('throws if the provided ref is not a tag ref', async () => {
await expect(async () =>
fsHelper.ensureTagAndRefCheckedOut(`refs/heads/main`, commit2, dir)
).rejects.toThrow()
})
})