@@ -792,6 +792,7 @@ describe("CLI commands", () => {
792792describe ( "imageTag priority behavior" , ( ) => {
793793 // Tests for the imageTag priority: --tag flag > PGAI_TAG env var > pkg.version
794794 // This verifies the fix that prevents stale .env PGAI_TAG from being used
795+ // These tests spawn subprocesses so need longer timeout
795796
796797 let tempDir : string ;
797798
@@ -814,11 +815,13 @@ describe("imageTag priority behavior", () => {
814815 fs . writeFileSync ( resolve ( testDir , "docker-compose.yml" ) , "version: '3'\nservices: {}\n" ) ;
815816
816817 // Run from the test directory (so resolvePaths finds docker-compose.yml)
818+ // Note: Command may hang on Docker check in CI without Docker, so we use a timeout
817819 const cliPath = resolve ( import . meta. dir , ".." , "bin" , "postgres-ai.ts" ) ;
818820 const bunBin = typeof process . execPath === "string" && process . execPath . length > 0 ? process . execPath : "bun" ;
819821 const result = Bun . spawnSync ( [ bunBin , cliPath , "mon" , "local-install" , "--db-url" , "postgresql://u:p@h:5432/d" , "--yes" ] , {
820822 env : { ...process . env , PGAI_TAG : undefined } ,
821823 cwd : testDir ,
824+ timeout : 30000 , // Kill subprocess after 30s if it hangs on Docker
822825 } ) ;
823826
824827 // Read the .env that was written
@@ -828,7 +831,7 @@ describe("imageTag priority behavior", () => {
828831 expect ( envContent ) . not . toMatch ( / P G A I _ T A G = b e t a / ) ;
829832 // It should contain the CLI version (0.0.0-dev.0 in dev)
830833 expect ( envContent ) . toMatch ( / P G A I _ T A G = \d + \. \d + \. \d + | P G A I _ T A G = 0 \. 0 \. 0 - d e v / ) ;
831- } ) ;
834+ } , 60000 ) ;
832835
833836 test ( "--tag flag takes priority over pkg.version" , ( ) => {
834837 const testDir = resolve ( tempDir , "tag-flag-test" ) ;
@@ -840,6 +843,7 @@ describe("imageTag priority behavior", () => {
840843 const result = Bun . spawnSync ( [ bunBin , cliPath , "mon" , "local-install" , "--tag" , "v1.2.3-custom" , "--db-url" , "postgresql://u:p@h:5432/d" , "--yes" ] , {
841844 env : { ...process . env , PGAI_TAG : undefined } ,
842845 cwd : testDir ,
846+ timeout : 30000 ,
843847 } ) ;
844848
845849 const envContent = fs . readFileSync ( resolve ( testDir , ".env" ) , "utf8" ) ;
@@ -848,7 +852,7 @@ describe("imageTag priority behavior", () => {
848852 // Verify stdout confirms the tag being used
849853 const stdout = new TextDecoder ( ) . decode ( result . stdout ) ;
850854 expect ( stdout ) . toMatch ( / U s i n g i m a g e t a g : v 1 \. 2 \. 3 - c u s t o m / ) ;
851- } ) ;
855+ } , 60000 ) ;
852856
853857 test ( "PGAI_TAG env var is intentionally ignored (Bun auto-loads .env)" , ( ) => {
854858 // Note: We do NOT use process.env.PGAI_TAG because Bun auto-loads .env files,
@@ -863,13 +867,14 @@ describe("imageTag priority behavior", () => {
863867 const result = Bun . spawnSync ( [ bunBin , cliPath , "mon" , "local-install" , "--db-url" , "postgresql://u:p@h:5432/d" , "--yes" ] , {
864868 env : { ...process . env , PGAI_TAG : "v2.0.0-from-env" } ,
865869 cwd : testDir ,
870+ timeout : 30000 ,
866871 } ) ;
867872
868873 const envContent = fs . readFileSync ( resolve ( testDir , ".env" ) , "utf8" ) ;
869874 // PGAI_TAG env var should be IGNORED - uses pkg.version instead
870875 expect ( envContent ) . not . toMatch ( / P G A I _ T A G = v 2 \. 0 \. 0 - f r o m - e n v / ) ;
871876 expect ( envContent ) . toMatch ( / P G A I _ T A G = \d + \. \d + \. \d + | P G A I _ T A G = 0 \. 0 \. 0 - d e v / ) ;
872- } ) ;
877+ } , 60000 ) ;
873878
874879 test ( "existing registry and password are preserved while tag is updated" , ( ) => {
875880 const testDir = resolve ( tempDir , "preserve-test" ) ;
@@ -884,6 +889,7 @@ describe("imageTag priority behavior", () => {
884889 const result = Bun . spawnSync ( [ bunBin , cliPath , "mon" , "local-install" , "--db-url" , "postgresql://u:p@h:5432/d" , "--yes" ] , {
885890 env : { ...process . env , PGAI_TAG : undefined } ,
886891 cwd : testDir ,
892+ timeout : 30000 ,
887893 } ) ;
888894
889895 const envContent = fs . readFileSync ( resolve ( testDir , ".env" ) , "utf8" ) ;
@@ -894,5 +900,5 @@ describe("imageTag priority behavior", () => {
894900 // But registry and password should be preserved
895901 expect ( envContent ) . toMatch ( / P G A I _ R E G I S T R Y = m y \. r e g i s t r y \. c o m / ) ;
896902 expect ( envContent ) . toMatch ( / G F _ S E C U R I T Y _ A D M I N _ P A S S W O R D = s e c r e t 1 2 3 / ) ;
897- } ) ;
903+ } , 60000 ) ;
898904} ) ;
0 commit comments