Skip to content

Commit bd52324

Browse files
committed
test(components-updates): prepare for mocking more https-request stuff
The `guessReleaseNotes()` function is about to learn how to retrieve Cygwin's release notes, and will need to be mocked accordingly. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 460dfa2 commit bd52324

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

__tests__/component-updates.test.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ jest.mock('../GitForWindowsHelper/github-api-request', () => {
5656
return mockGithubApiRequest
5757
})
5858

59+
const missingURL = 'https://wingit.blob.core.windows.net/x86-64/curl-8.1.2-1-x86_64.pkg.tar.xz'
60+
const missingMinTTYURL = 'https://wingit.blob.core.windows.net/i686/mintty-1~3.6.5-1-i686.pkg.tar.xz'
61+
const bogus32BitMSYS2RuntimeURL = 'https://wingit.blob.core.windows.net/i686/msys2-runtime-3.4.9-1-i686.pkg.tar.xz'
62+
const bogus64BitMSYS2RuntimeURL = 'https://wingit.blob.core.windows.net/x86-64/msys2-runtime-3.3-3.3.7-1-x86_64.pkg.tar.xz'
63+
const mockDoesURLReturn404 = jest.fn(url => [
64+
missingURL, missingMinTTYURL, bogus32BitMSYS2RuntimeURL, bogus64BitMSYS2RuntimeURL
65+
].includes(url))
66+
jest.mock('../GitForWindowsHelper/https-request', () => {
67+
return { doesURLReturn404: mockDoesURLReturn404, }
68+
})
69+
70+
5971
test('guessReleaseNotes()', async () => {
6072
const context = { log: jest.fn() }
6173
expect(await guessReleaseNotes(context, {
@@ -130,17 +142,6 @@ http://www.gnutls.org/news.html#2023-02-10`
130142
})
131143

132144
test('getMissingDeployments()', async () => {
133-
const missingURL = 'https://wingit.blob.core.windows.net/x86-64/curl-8.1.2-1-x86_64.pkg.tar.xz'
134-
const missingMinTTYURL = 'https://wingit.blob.core.windows.net/i686/mintty-1~3.6.5-1-i686.pkg.tar.xz'
135-
const bogus32BitMSYS2RuntimeURL = 'https://wingit.blob.core.windows.net/i686/msys2-runtime-3.4.9-1-i686.pkg.tar.xz'
136-
const bogus64BitMSYS2RuntimeURL = 'https://wingit.blob.core.windows.net/x86-64/msys2-runtime-3.3-3.3.7-1-x86_64.pkg.tar.xz'
137-
const mockDoesURLReturn404 = jest.fn(url => [
138-
missingURL, missingMinTTYURL, bogus32BitMSYS2RuntimeURL, bogus64BitMSYS2RuntimeURL
139-
].includes(url))
140-
jest.mock('../GitForWindowsHelper/https-request', () => {
141-
return { doesURLReturn404: mockDoesURLReturn404 }
142-
})
143-
144145
expect(await getMissingDeployments('curl', '8.1.2')).toEqual([missingURL])
145146
expect(await getMissingDeployments('mintty', '3.6.5')).toEqual([missingMinTTYURL])
146147
expect(await getMissingDeployments('msys2-runtime', '3.4.9')).toEqual([])

0 commit comments

Comments
 (0)