Skip to content

Commit b0ffada

Browse files
committed
Add a unit test for component-updates
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 56be281 commit b0ffada

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
const {
2+
guessComponentUpdateDetails,
3+
guessReleaseNotes
4+
} = require('../GitForWindowsHelper/component-updates')
5+
6+
const bashTicketBody = `# [New bash version] Bash-5.2 patch 15: fix too-aggressive optimizing forks out of subshell commands
7+
8+
<div type="text"/>
9+
10+
https://git.savannah.gnu.org/cgit/bash.git/commit/?id=ec8113b9861375e4e17b3307372569d429dec814
11+
12+
# [New bash version] Bash-5.2 patch 14: process additional terminating signals when running the EXIT trap after a terminating signal
13+
14+
<div type="text"/>
15+
16+
https://git.savannah.gnu.org/cgit/bash.git/commit/?id=6647917a43dd987c5564cc20d0943213b39e748b
17+
18+
# [New bash version] Bash-5.2 patch 13: fix memory leak referencing a nonexistent associative array element
19+
20+
<div type="text"/>
21+
22+
https://git.savannah.gnu.org/cgit/bash.git/commit/?id=52f2cda1a2156c8532f2f49391470cf2f66a1bd0`
23+
24+
test('guessComponentUpdateDetails()', () => {
25+
const titles = [
26+
['[New cygwin version] cygwin-3.4.4', 'msys2-runtime', '3.4.4'],
27+
['[New libcbor version] v0.10.2', 'libcbor', '0.10.2'],
28+
['[New openssl version] OpenSSL 1.1.1s', 'openssl', '1.1.1s'],
29+
['[New openssh version] V_9_2_P1', 'openssh', '9.2.P1'],
30+
['[New tig version] tig-2.5.8', 'tig', '2.5.8'],
31+
['[New curl version] 7.87.0', 'curl', '7.87.0'],
32+
['[New mintty version] 3.6.3', 'mintty', '3.6.3'],
33+
['[New pcre2 version] PCRE2-10.42', 'pcre2', '10.42'],
34+
['[New git-lfs version] v3.3.0', 'mingw-w64-git-lfs', '3.3.0'],
35+
['[New heimdal version] Heimdal 7.7.1 - Security Fix Release', 'heimdal', '7.7.1']
36+
]
37+
for (const [title, package_name, version] of titles) {
38+
expect(guessComponentUpdateDetails(title)).toEqual({ package_name, version })
39+
}
40+
41+
expect(guessComponentUpdateDetails('[New bash version] 3 new items', bashTicketBody)).toEqual({
42+
package_name: 'bash',
43+
version: '5.2.15'
44+
})
45+
})
46+
47+
let mockGithubApiRequest = jest.fn(() => {
48+
return {
49+
}
50+
})
51+
jest.mock('../GitForWindowsHelper/github-api-request', () => {
52+
return mockGithubApiRequest
53+
})
54+
55+
test('guessReleaseNotes()', async () => {
56+
const context = { log: jest.fn() }
57+
expect(await guessReleaseNotes(context, {
58+
labels: [{ name: 'component-update' }],
59+
title: '[New bash version] 3 new items',
60+
body: bashTicketBody
61+
})).toEqual({
62+
type: 'feature',
63+
message: 'Comes with [Bash v5.2.15](https://git.savannah.gnu.org/cgit/bash.git/commit/?id=ec8113b9861375e4e17b3307372569d429dec814).'
64+
})
65+
})

0 commit comments

Comments
 (0)