Skip to content

Commit 8c4f8c3

Browse files
fix: flaky apps:diff tests (#3649)
resolve slug checksums sequentially and drop unused app2 nock mocks in 404 tests to stop flaky unit failures
1 parent 1d27c09 commit 8c4f8c3

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

src/commands/apps/diff.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ async function checksum(heroku: APIClient, app: string): Promise<string | null>
4545
}
4646

4747
async function diffFiles(heroku: APIClient, app1: string, app2: string): Promise<DiffRow[]> {
48-
const sums = await Promise.all([checksum(heroku, app1), checksum(heroku, app2)])
49-
return sums[0] === sums[1] ? [] : [{prop: 'slug (checksum)', app1: sums[0] ?? undefined, app2: sums[1] ?? undefined}]
48+
const sum1 = await checksum(heroku, app1)
49+
const sum2 = await checksum(heroku, app2)
50+
return sum1 === sum2 ? [] : [{prop: 'slug (checksum)', app1: sum1 ?? undefined, app2: sum2 ?? undefined}]
5051
}
5152

5253
async function diffEnv(heroku: APIClient, app1: string, app2: string): Promise<DiffRow[]> {

test/unit/commands/apps/diff.unit.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ describe('apps:diff', function () {
132132
it('throws App not found when one app returns 404 on releases', async function () {
133133
api
134134
.get(`/apps/${app1Name}/releases`).matchHeader('range', /version/).reply(404, {id: 'not_found', message: 'Couldn\'t find that app.'})
135-
.get(`/apps/${app2Name}/releases`).matchHeader('range', /version/).reply(200, releasesWithSlug(slugId2))
136-
.get(`/apps/${app2Name}/slugs/${slugId2}`).optionally().reply(200, slugBody(sameChecksum))
137135

138136
const {error} = await runCommand(AppsDiff, [app1Name, app2Name])
139137

@@ -146,8 +144,6 @@ describe('apps:diff', function () {
146144
api
147145
.get(`/apps/${app1Name}/releases`).matchHeader('range', /version/).reply(200, releasesWithSlug(slugId1))
148146
.get(`/apps/${app1Name}/slugs/${slugId1}`).reply(404, {id: 'not_found', message: 'Not found'})
149-
.get(`/apps/${app2Name}/releases`).matchHeader('range', /version/).reply(200, releasesWithSlug(slugId2))
150-
.get(`/apps/${app2Name}/slugs/${slugId2}`).reply(200, slugBody(sameChecksum))
151147

152148
const {error} = await runCommand(AppsDiff, [app1Name, app2Name])
153149

0 commit comments

Comments
 (0)