@@ -10,21 +10,20 @@ describe('assembleConfig', () => {
1010 remotePath : '/var/www/app' ,
1111 } ) ;
1212
13- expect ( config . app ) . toBe ( 'backend' ) ;
13+ expect ( config . apps [ 0 ] . appType ) . toBe ( 'backend' ) ;
1414 expect ( config . ssh . host ) . toBe ( '192.168.1.1' ) ;
1515 expect ( config . ssh . user ) . toBe ( 'deploy' ) ;
1616 expect ( config . ssh . port ) . toBe ( 22 ) ;
1717 expect ( config . remotePath ) . toBe ( '/var/www/app' ) ;
18- expect ( config . keepReleases ) . toBe ( 5 ) ;
19- expect ( config . healthCheck . enabled ) . toBe ( true ) ;
20- expect ( config . healthCheck . path ) . toBe ( '/health' ) ;
21- expect ( config . healthCheck . timeout ) . toBe ( 30 ) ;
22- expect ( config . healthCheck . retries ) . toBe ( 3 ) ;
23- expect ( config . healthCheck . startupDelay ) . toBe ( 3 ) ;
24- expect ( config . envFile ) . toBe ( '.env' ) ;
18+ expect ( config . apps [ 0 ] . keepReleases ) . toBe ( 5 ) ;
19+ expect ( config . apps [ 0 ] . healthCheck . enabled ) . toBe ( true ) ;
20+ expect ( config . apps [ 0 ] . healthCheck . path ) . toBe ( '/health' ) ;
21+ expect ( config . apps [ 0 ] . healthCheck . timeout ) . toBe ( 30 ) ;
22+ expect ( config . apps [ 0 ] . healthCheck . retries ) . toBe ( 3 ) ;
23+ expect ( config . apps [ 0 ] . healthCheck . startupDelay ) . toBe ( 3 ) ;
24+ expect ( config . apps [ 0 ] . envFile ) . toBe ( '.env' ) ;
2525 expect ( config . nodeVersion ) . toBe ( 'lts' ) ;
26- // No pm2 declared → no apps at all.
27- expect ( config . pm2 ) . toBeUndefined ( ) ;
26+ expect ( config . apps [ 0 ] . pm2 ) . toBeUndefined ( ) ;
2827 } ) ;
2928
3029 it ( 'preserves explicitly provided values' , ( ) => {
@@ -38,13 +37,13 @@ describe('assembleConfig', () => {
3837 nodeVersion : '22' ,
3938 } ) ;
4039
41- expect ( config . app ) . toBe ( 'frontend' ) ;
40+ expect ( config . apps [ 0 ] . appType ) . toBe ( 'frontend' ) ;
4241 expect ( config . ssh . port ) . toBe ( 2222 ) ;
4342 expect ( config . remotePath ) . toBe ( '/opt/app' ) ;
44- expect ( config . keepReleases ) . toBe ( 10 ) ;
45- expect ( config . healthCheck . path ) . toBe ( '/api/health' ) ;
46- expect ( config . healthCheck . timeout ) . toBe ( 60 ) ;
47- expect ( config . envFile ) . toBe ( '.env.production' ) ;
43+ expect ( config . apps [ 0 ] . keepReleases ) . toBe ( 10 ) ;
44+ expect ( config . apps [ 0 ] . healthCheck . path ) . toBe ( '/api/health' ) ;
45+ expect ( config . apps [ 0 ] . healthCheck . timeout ) . toBe ( 60 ) ;
46+ expect ( config . apps [ 0 ] . envFile ) . toBe ( '.env.production' ) ;
4847 expect ( config . nodeVersion ) . toBe ( '22' ) ;
4948 } ) ;
5049
@@ -56,8 +55,8 @@ describe('assembleConfig', () => {
5655 pm2 : { name : 'api' , instances : 2 , maxMemory : '1G' } ,
5756 backend : { port : 8080 } ,
5857 } ) ;
59- expect ( config . pm2 ?. apps ) . toHaveLength ( 1 ) ;
60- expect ( config . pm2 ?. apps [ 0 ] ) . toMatchObject ( { name : 'api' , port : 8080 , instances : 2 , maxMemory : '1G' } ) ;
58+ expect ( config . apps [ 0 ] . pm2 ?. apps ) . toHaveLength ( 1 ) ;
59+ expect ( config . apps [ 0 ] . pm2 ?. apps [ 0 ] ) . toMatchObject ( { name : 'api' , port : 8080 , instances : 2 , maxMemory : '1G' } ) ;
6160 } ) ;
6261
6362 it ( 'accepts the new pm2.apps input shape directly' , ( ) => {
@@ -67,9 +66,9 @@ describe('assembleConfig', () => {
6766 remotePath : '/var/www/app' ,
6867 pm2 : { apps : [ { name : 'api' , port : 3000 } , { name : 'worker' , command : 'node dist/worker.js' } ] } ,
6968 } ) ;
70- expect ( config . pm2 ?. apps ) . toHaveLength ( 2 ) ;
71- expect ( config . pm2 ?. apps [ 0 ] . name ) . toBe ( 'api' ) ;
72- expect ( config . pm2 ?. apps [ 1 ] . name ) . toBe ( 'worker' ) ;
69+ expect ( config . apps [ 0 ] . pm2 ?. apps ) . toHaveLength ( 2 ) ;
70+ expect ( config . apps [ 0 ] . pm2 ?. apps [ 0 ] . name ) . toBe ( 'api' ) ;
71+ expect ( config . apps [ 0 ] . pm2 ?. apps [ 1 ] . name ) . toBe ( 'worker' ) ;
7372 } ) ;
7473
7574 it ( 'rejects two pm2.apps entries with ports' , ( ) => {
@@ -122,22 +121,6 @@ describe('assembleConfig', () => {
122121 expect ( config . apps [ 0 ] . appType ) . toBe ( 'frontend' ) ;
123122 } ) ;
124123
125- it ( 'legacy top-level mirrors are kept in sync with apps[0]' , ( ) => {
126- const config = assembleConfig ( {
127- app : 'backend' ,
128- ssh : { host : '1.2.3.4' , user : 'deploy' } ,
129- remotePath : '/var/www/app' ,
130- pm2 : { apps : [ { name : 'api' , port : 3000 } ] } ,
131- domain : 'api.example.com' ,
132- envFile : '.env.production' ,
133- } ) ;
134- expect ( config . app ) . toBe ( config . apps [ 0 ] . appType ) ;
135- expect ( config . domain ) . toBe ( config . apps [ 0 ] . domain ) ;
136- expect ( config . envFile ) . toBe ( config . apps [ 0 ] . envFile ) ;
137- expect ( config . pm2 ) . toBe ( config . apps [ 0 ] . pm2 ) ;
138- expect ( config . healthCheck ) . toEqual ( config . apps [ 0 ] . healthCheck ) ;
139- } ) ;
140-
141124 it ( 'preserves aliases through assembly' , ( ) => {
142125 const config = assembleConfig ( {
143126 app : 'backend' ,
@@ -179,6 +162,6 @@ describe('assembleConfig', () => {
179162 remotePath : '/var/www/app' ,
180163 } ) ;
181164
182- expect ( config . app ) . toBe ( 'backend' ) ;
165+ expect ( config . apps [ 0 ] . appType ) . toBe ( 'backend' ) ;
183166 } ) ;
184167} ) ;
0 commit comments