@@ -18,6 +18,7 @@ import * as Sink from "effect/Sink";
1818import * as Stream from "effect/Stream" ;
1919import { FetchHttpClient } from "effect/http" ;
2020import { ChildProcess , ChildProcessSpawner } from "effect/process" ;
21+ import * as TestClock from "effect/testing/TestClock" ;
2122import * as TestConsole from "effect/testing/TestConsole" ;
2223import { Command , CliError } from "effect/cli" ;
2324
@@ -548,3 +549,42 @@ describe("auth pairing create --base-url", () => {
548549 } ) ,
549550 ) ;
550551} ) ;
552+
553+ describe ( "scripted auth output" , ( ) => {
554+ it . effect . each (
555+ [
556+ [ "auth" , "session" , "issue" , "--token-only" ] ,
557+ [ "auth" , "session" , "list" , "--json" ] ,
558+ [ "auth" , "pairing" , "list" , "--json" ] ,
559+ ] . map ( ( command ) => ( { command, label : command . join ( " " ) } ) ) ,
560+ ) ( "prints only the result for $label after removing an abandoned upload" , ( { command } ) =>
561+ Effect . gen ( function * ( ) {
562+ const baseDir = NodeFS . mkdtempSync ( NodePath . join ( NodeOS . tmpdir ( ) , "t3-cli-quiet-test-" ) ) ;
563+ const attachmentsDir = NodePath . join ( baseDir , "userdata" , "attachments" ) ;
564+ NodeFS . mkdirSync ( attachmentsDir , { recursive : true } ) ;
565+ // An abandoned upload makes config resolution log that it removed it.
566+ const abandoned = NodePath . join ( attachmentsDir , "abandoned.part" ) ;
567+ NodeFS . writeFileSync ( abandoned , "" ) ;
568+ const jan2020Seconds = 1_577_836_800 ;
569+ NodeFS . utimesSync ( abandoned , jan2020Seconds , jan2020Seconds ) ;
570+ // The sweep reads Clock, so a week past the upload's mtime makes it expired.
571+ yield * TestClock . setTime ( ( jan2020Seconds + 7 * 24 * 60 * 60 ) * 1000 ) ;
572+
573+ const lines = yield * provideCliTestLayers (
574+ Effect . gen ( function * ( ) {
575+ yield * runCli ( [ ...command , "--base-dir" , baseDir ] ) ;
576+ return yield * TestConsole . logLines ;
577+ } ) ,
578+ ) ;
579+
580+ assert . isFalse ( NodeFS . existsSync ( abandoned ) ) ;
581+ assert . lengthOf ( lines , 1 ) ;
582+ const output = String ( lines [ 0 ] ) ;
583+ if ( command . includes ( "--json" ) ) {
584+ assert . deepEqual ( JSON . parse ( output ) , [ ] ) ;
585+ } else {
586+ assert . match ( output . trim ( ) , / ^ [ \w - ] + \. [ \w - ] + / ) ;
587+ }
588+ } ) ,
589+ ) ;
590+ } ) ;
0 commit comments