Skip to content

Commit

Permalink
Apply git desync fix to getAllTags tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Lucas committed Oct 11, 2021
1 parent 1487538 commit 4204c86
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/git/src/Git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ describe('Git', () => {
let dir = ''
let spawn = getSpawn(dir)

async function waitToFixGitTime() {
await new Promise((r) => setTimeout(r, 500))
async function waitToFixGitTime(ms = 500) {
await new Promise((r) => setTimeout(r, ms))
}

function writeFile(name: string, text: string) {
Expand Down Expand Up @@ -679,6 +679,7 @@ describe('Git', () => {
await spawn(['init'])
writeFile('f1.txt', 'abc')
const sha1 = await commit('First Commit')
await waitToFixGitTime(1000)
writeFile('f2.txt', 'abc')
const sha2 = await commit('Second Commit')

Expand All @@ -691,16 +692,16 @@ describe('Git', () => {

const tags = await git.getAllTags()
expect(tags).toEqual([
expect.objectContaining({
headSHA: sha1,
id: 'refs/tags/tag1',
name: 'tag1',
}),
expect.objectContaining({
headSHA: sha2,
id: 'refs/tags/tag2',
name: 'tag2',
}),
expect.objectContaining({
headSHA: sha1,
id: 'refs/tags/tag1',
name: 'tag1',
}),
])

// Check that the deleted variable data meets correct rules
Expand Down Expand Up @@ -729,6 +730,7 @@ describe('Git', () => {

await spawn(['checkout', sha1])
await spawn(['tag', 'tag1'])
await waitToFixGitTime()
await spawn(['checkout', branchName])
await spawn(['tag', 'tag2'])
await spawn(['push', '--tags'])
Expand Down

0 comments on commit 4204c86

Please sign in to comment.