Skip to content

Commit 2c350dd

Browse files
ryzokukenjoyeecheung
authored andcommitted
test: add tests for cross-repository/cross-owner fixes (#197)
Fixes: #75
1 parent 5e9d9dc commit 2c350dd

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

test/fixtures/data.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const firstTimerPR = readJSON('first_timer_pr.json');
5959
const firstTimerPrivatePR = readJSON('first_timer_pr_with_private_email.json');
6060
const semverMajorPR = readJSON('semver_major_pr.json');
6161
const fixAndRefPR = readJSON('pr_with_fixes_and_refs.json');
62+
const fixCrossPR = readJSON('pr_with_fixes_cross.json');
6263
const conflictingPR = readJSON('conflicting_pr.json');
6364
const emptyProfilePR = readJSON('empty_profile_pr.json');
6465
const closedPR = readJSON('./closed_pr.json');
@@ -92,6 +93,7 @@ module.exports = {
9293
firstTimerPrivatePR,
9394
semverMajorPR,
9495
fixAndRefPR,
96+
fixCrossPR,
9597
conflictingPR,
9698
emptyProfilePR,
9799
readme,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"createdAt": "2017-10-24T11:13:43Z",
3+
"url": "https://github.com/nodejs/node/pull/16438",
4+
"bodyHTML":
5+
"<p>Fixes: <a href=\"https://github.com/joyeecheung/node-core-utils/issues/123\" class=\"issue-link js-issue-link\" data-error-text=\"Failed to load issue title\" data-id=\"271243248\" data-permission-text=\"Issue title is private\" data-url=\"https://github.com/joyeecheung/node-core-utils/issues/123\">joyeecheung/node-core-utils#123</a></p>",
6+
"bodyText": "Fixes: joyeecheung/node-core-utils#123",
7+
"labels": {
8+
"nodes": [
9+
{
10+
"name": "build"
11+
},
12+
{
13+
"name": "npm"
14+
},
15+
{
16+
"name": "python"
17+
}
18+
]
19+
}
20+
}

test/unit/metadata_gen.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const MetadataGenerator = require('../../lib/metadata_gen');
44
const {
55
fixAndRefPR,
6+
fixCrossPR,
67
allGreenReviewers
78
} = require('../fixtures/data');
89

@@ -13,6 +14,7 @@ const data = {
1314
pr: fixAndRefPR,
1415
reviewers: allGreenReviewers
1516
};
17+
const crossData = Object.assign({}, data, { pr: fixCrossPR });
1618

1719
const expected = `PR-URL: https://github.com/nodejs/node/pull/16438
1820
Fixes: https://github.com/nodejs/node/issues/16437
@@ -22,10 +24,23 @@ Reviewed-By: Quux User <quux@example.com>
2224
Reviewed-By: Baz User <baz@example.com>
2325
Reviewed-By: Bar User <bar@example.com>
2426
`;
27+
const crossExpected = `PR-URL: https://github.com/nodejs/node/pull/16438
28+
Fixes: https://github.com/joyeecheung/node-core-utils/issues/123
29+
Reviewed-By: Foo User <foo@example.com>
30+
Reviewed-By: Quux User <quux@example.com>
31+
Reviewed-By: Baz User <baz@example.com>
32+
Reviewed-By: Bar User <bar@example.com>
33+
`;
2534

2635
describe('MetadataGenerator', () => {
2736
it('should generate metadata properly', () => {
2837
const results = new MetadataGenerator(data).getMetadata();
2938
assert.strictEqual(expected, results);
3039
});
40+
41+
it('should handle cross-owner and cross-repo fixes properly', () => {
42+
const results = new MetadataGenerator(crossData).getMetadata();
43+
console.log(results);
44+
assert.strictEqual(crossExpected, results);
45+
});
3146
});

0 commit comments

Comments
 (0)