@@ -31,14 +31,17 @@ const here = dirname(fileURLToPath(import.meta.url));
3131const script = join ( here , 'upsert-bot-comment.sh' ) ;
3232const MARKER = '<!-- test-marker -->' ;
3333
34- function run ( scenario , { updateOnly = false , botLogin = '' } = { } ) {
34+ function run (
35+ scenario ,
36+ { updateOnly = false , botLogin = '' , body = `${ MARKER } \nhello` } = { } ,
37+ ) {
3538 const dir = mkdtempSync ( join ( tmpdir ( ) , 'upsert-bot-comment-' ) ) ;
3639 const bin = join ( dir , 'bin' ) ;
3740 mkdirSync ( bin ) ;
3841 const calls = join ( dir , 'calls' ) ;
3942 writeFileSync ( calls , '' ) ;
4043 const bodyFile = join ( dir , 'body' ) ;
41- writeFileSync ( bodyFile , ` ${ MARKER } \nhello` ) ;
44+ writeFileSync ( bodyFile , body ) ;
4245 const write = ( name , body ) => {
4346 writeFileSync ( join ( bin , name ) , body ) ;
4447 chmodSync ( join ( bin , name ) , 0o755 ) ;
@@ -49,6 +52,7 @@ function run(scenario, { updateOnly = false, botLogin = '' } = {}) {
4952 [
5053 '#!/bin/bash' ,
5154 'echo "$*" >> "$CALLS"' ,
55+ 'if [[ "$*" == *"--input -"* ]]; then cat >/dev/null; fi' ,
5256 'n=$(grep -c "method GET" "$CALLS" || true)' ,
5357 'case "$*" in' ,
5458 ' "api user"*)' ,
@@ -120,6 +124,15 @@ test('uses BOT_LOGIN when the token cannot access /user', () => {
120124 assert . doesNotMatch ( r . calls , / a p i u s e r / ) ;
121125} ) ;
122126
127+ test ( 'streams large comment bodies through stdin' , ( ) => {
128+ const r = run ( 'fresh' , {
129+ body : `${ MARKER } \n${ 'x' . repeat ( 200_000 ) } ` ,
130+ } ) ;
131+ assert . equal ( r . code , 0 ) ;
132+ assert . match ( r . calls , / - - m e t h o d P O S T .* - - i n p u t - / ) ;
133+ assert . doesNotMatch ( r . calls , / b o d y = / ) ;
134+ } ) ;
135+
123136test ( 'PATCHes the existing bot-authored marker comment' , ( ) => {
124137 const r = run ( 'existing-bot' ) ;
125138 assert . equal ( r . code , 0 ) ;
@@ -149,7 +162,7 @@ test('--update-only is a no-op success when nothing exists', () => {
149162 assert . match ( r . stdout , / n o t h i n g t o u p d a t e / ) ;
150163 assert . doesNotMatch ( r . calls , / - - m e t h o d P A T C H / ) ;
151164 // And no POST either: the only api writes would be comment creation.
152- assert . doesNotMatch ( r . calls , / i s s u e s \/ 4 2 \/ c o m m e n t s - f / ) ;
165+ assert . doesNotMatch ( r . calls , / - - m e t h o d P O S T / ) ;
153166} ) ;
154167
155168test ( 'a failed listing NEVER falls through to POST (retries, then PATCHes)' , ( ) => {
@@ -159,7 +172,7 @@ test('a failed listing NEVER falls through to POST (retries, then PATCHes)', ()
159172 const r = run ( 'listing-fails-once' ) ;
160173 assert . equal ( r . code , 0 ) ;
161174 assert . match ( r . stdout , / u p d a t e d c o m m e n t 7 / ) ;
162- assert . doesNotMatch ( r . calls , / i s s u e s \/ 4 2 \/ c o m m e n t s - f / ) ;
175+ assert . doesNotMatch ( r . calls , / - - m e t h o d P O S T / ) ;
163176} ) ;
164177
165178test ( 'a persistently failing identity lookup exits 1 without writing' , ( ) => {
0 commit comments