You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add integration tests for checkLegalBoilerplate orchestration function
Extract checkLegalBoilerplate() from dangerfile.js into dangerfile-utils.js
with dependency injection (accepts { danger, fail, markdown } as parameters)
so the orchestration logic can be tested without the DangerJS runtime.
Adds 19 tests covering author association filtering, template discovery,
missing/mismatched boilerplate detection, success cases, and markdown output.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
// Check if PR body contains the legal boilerplate section
183
+
if(!actualBoilerplate){
184
+
fail('This PR is missing the required legal boilerplate. As an external contributor, please include the "Legal Boilerplate" section from the PR template in your PR description.');
185
+
186
+
markdown(`
187
+
### ⚖️ Legal Boilerplate Required
188
+
189
+
As an external contributor, your PR must include the legal boilerplate from the PR template.
190
+
191
+
Please add the following section to your PR description:
192
+
193
+
\`\`\`markdown
194
+
${expectedBoilerplate}
195
+
\`\`\`
196
+
197
+
This is required to ensure proper intellectual property rights for your contributions.
198
+
`.trim());
199
+
return;
200
+
}
201
+
202
+
// Verify the actual boilerplate matches the expected one
fail('The legal boilerplate in your PR description does not match the template. Please ensure you include the complete, unmodified legal text from the PR template.');
210
+
211
+
markdown(`
212
+
### ⚖️ Legal Boilerplate Mismatch
213
+
214
+
Your PR contains a "Legal Boilerplate" section, but it doesn't match the required text from the template.
215
+
216
+
Please replace it with the exact text from the template:
217
+
218
+
\`\`\`markdown
219
+
${expectedBoilerplate}
220
+
\`\`\`
221
+
222
+
This is required to ensure proper intellectual property rights for your contributions.
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
535
+
536
+
## Checklist
537
+
- [ ] Tests added`;
538
+
539
+
constLEGAL_TEXT='Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here\'s the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry\'s choice of terms.';
540
+
541
+
/**
542
+
* Build a mock danger context for checkLegalBoilerplate tests.
543
+
* @param {object} overrides - Properties to override on danger.github.pr
544
+
* @param {string|null} templateContent - Content returned by fileContents for template paths (null = no template)
0 commit comments