@@ -395,6 +395,11 @@ describe("Dependency Resolver", () => {
395395 describe ( "printDependencyGraph" , ( ) => {
396396 let logOutput : string [ ]
397397 let originalLog : typeof console . log
398+ const testApp : Schema . DeployableComponent = {
399+ name : "test-app" , id : "test-app" ,
400+ location : { type : Schema . LocationType . Local } ,
401+ deploy : { command : "deploy.sh" } , undeploy : { command : "undeploy.sh" }
402+ }
398403 beforeEach ( ( ) => {
399404 logOutput = [ ]
400405 originalLog = console . log
@@ -410,9 +415,10 @@ describe("Dependency Resolver", () => {
410415 { name : "B" , id : "b" , location : { type : Schema . LocationType . Local } , deploy : { command : "deploy.sh" } , undeploy : { command : "undeploy.sh" } } ,
411416 { name : "C" , id : "c" , location : { type : Schema . LocationType . Local } , deploy : { command : "deploy.sh" } , undeploy : { command : "undeploy.sh" } }
412417 ]
413- printDependencyGraph ( components )
418+ printDependencyGraph ( { testApp , components } )
414419 expect ( logOutput [ 0 ] ) . to . equal ( "Dependency Graph" )
415420 expect ( logOutput ) . to . include ( " Stage 1 │ a b c" )
421+ expect ( logOutput ) . to . include ( " Stage 2 │ test-app" )
416422 } )
417423
418424 it ( "prints graph for components with dependencies at multiple stages" , ( ) => {
@@ -421,10 +427,11 @@ describe("Dependency Resolver", () => {
421427 { name : "API" , id : "api" , location : { type : Schema . LocationType . Local } , deploy : { command : "deploy.sh" } , undeploy : { command : "undeploy.sh" } , dependsOn : [ "db" ] } ,
422428 { name : "Cache" , id : "cache" , location : { type : Schema . LocationType . Local } , deploy : { command : "deploy.sh" } , undeploy : { command : "undeploy.sh" } , dependsOn : [ "db" ] }
423429 ]
424- printDependencyGraph ( components )
430+ printDependencyGraph ( { testApp , components } )
425431 expect ( logOutput [ 0 ] ) . to . equal ( "Dependency Graph" )
426432 expect ( logOutput ) . to . include ( " Stage 1 │ db" )
427433 expect ( logOutput ) . to . include ( " Stage 2 │ api cache" )
434+ expect ( logOutput ) . to . include ( " Stage 3 │ test-app" )
428435 expect ( logOutput ) . to . include ( " db ──▶ api" )
429436 expect ( logOutput ) . to . include ( " db ──▶ cache" )
430437 } )
@@ -435,11 +442,12 @@ describe("Dependency Resolver", () => {
435442 { name : "B" , id : "b" , location : { type : Schema . LocationType . Local } , deploy : { command : "deploy.sh" } , undeploy : { command : "undeploy.sh" } , dependsOn : [ "a" ] } ,
436443 { name : "C" , id : "c" , location : { type : Schema . LocationType . Local } , deploy : { command : "deploy.sh" } , undeploy : { command : "undeploy.sh" } , dependsOn : [ "b" ] }
437444 ]
438- printDependencyGraph ( components )
445+ printDependencyGraph ( { testApp , components } )
439446 expect ( logOutput [ 0 ] ) . to . equal ( "Dependency Graph" )
440447 expect ( logOutput ) . to . include ( " Stage 1 │ a" )
441448 expect ( logOutput ) . to . include ( " Stage 2 │ b" )
442449 expect ( logOutput ) . to . include ( " Stage 3 │ c" )
450+ expect ( logOutput ) . to . include ( " Stage 4 │ test-app" )
443451 expect ( logOutput ) . to . include ( " a ──▶ b" )
444452 expect ( logOutput ) . to . include ( " b ──▶ c" )
445453 } )
@@ -450,13 +458,29 @@ describe("Dependency Resolver", () => {
450458 { name : "B" , id : "b" , location : { type : Schema . LocationType . Local } , deploy : { command : "deploy.sh" } , undeploy : { command : "undeploy.sh" } , dependsOn : [ "a" ] , parallel : true } ,
451459 { name : "C" , id : "c" , location : { type : Schema . LocationType . Local } , deploy : { command : "deploy.sh" } , undeploy : { command : "undeploy.sh" } , dependsOn : [ "a" ] , parallel : true }
452460 ]
453- printDependencyGraph ( components )
461+ printDependencyGraph ( { testApp , components } )
454462 expect ( logOutput [ 0 ] ) . to . equal ( "Dependency Graph" )
455463 expect ( logOutput ) . to . include ( " Stage 1 │ a" )
456464 expect ( logOutput ) . to . include ( " Stage 2 │ b 🔀 c 🔀" )
465+ expect ( logOutput ) . to . include ( " Stage 3 │ test-app" )
457466 expect ( logOutput ) . to . include ( " a ──▶ b" )
458467 expect ( logOutput ) . to . include ( " a ──▶ c" )
459468 expect ( logOutput ) . to . include ( " 🔀 = concurrent deployment" )
460469 } )
470+
471+ it ( "shows testApp in a concurrent section when testApp.parallel is true" , ( ) => {
472+ const parallelTestApp : Schema . DeployableComponent = { ...testApp , id : "my-test-app" , parallel : true }
473+ const components : Array < Schema . DeployableComponent > = [
474+ { name : "A" , id : "a" , location : { type : Schema . LocationType . Local } , deploy : { command : "deploy.sh" } , undeploy : { command : "undeploy.sh" } } ,
475+ { name : "B" , id : "b" , location : { type : Schema . LocationType . Local } , deploy : { command : "deploy.sh" } , undeploy : { command : "undeploy.sh" } , dependsOn : [ "a" ] }
476+ ]
477+ printDependencyGraph ( { testApp : parallelTestApp , components } )
478+ expect ( logOutput [ 0 ] ) . to . equal ( "Dependency Graph" )
479+ expect ( logOutput ) . to . include ( " Stage 1 │ a" )
480+ expect ( logOutput ) . to . include ( " Stage 2 │ b" )
481+ expect ( logOutput ) . to . include ( " my-test-app 🔀 (concurrent with component stages)" )
482+ expect ( logOutput ) . to . not . include ( " Stage 3 │ my-test-app" )
483+ expect ( logOutput ) . to . include ( " 🔀 = concurrent deployment" )
484+ } )
461485 } )
462486} )
0 commit comments