@@ -7,8 +7,14 @@ import { CloudAssemblyBuilder } from '@aws-cdk/cx-api';
7
7
import { expect } from '@jest/globals' ;
8
8
import { WorkGraph , WorkGraphBuilder } from '../../../lib/api/work-graph' ;
9
9
import type { AssetBuildNode , AssetPublishNode , StackNode , WorkNode } from '../../../lib/api/work-graph' ;
10
+ import { CliIoHost , IoMessaging } from '../../../lib/toolkit/cli-io-host' ;
10
11
11
12
let rootBuilder : CloudAssemblyBuilder ;
13
+ let mockMsg : IoMessaging = {
14
+ ioHost : CliIoHost . instance ( ) ,
15
+ action : 'deploy'
16
+ } ;
17
+
12
18
beforeEach ( ( ) => {
13
19
rootBuilder = new CloudAssemblyBuilder ( ) ;
14
20
} ) ;
@@ -44,7 +50,7 @@ describe('with some stacks and assets', () => {
44
50
} ) ;
45
51
46
52
test ( 'stack depends on the asset publishing step' , ( ) => {
47
- const graph = new WorkGraphBuilder ( true ) . build ( assembly . artifacts ) ;
53
+ const graph = new WorkGraphBuilder ( mockMsg , true ) . build ( assembly . artifacts ) ;
48
54
49
55
expect ( assertableNode ( graph . node ( 'stack2' ) ) ) . toEqual ( expect . objectContaining ( {
50
56
type : 'stack' ,
@@ -53,7 +59,7 @@ describe('with some stacks and assets', () => {
53
59
} ) ;
54
60
55
61
test ( 'asset publishing step depends on asset building step' , ( ) => {
56
- const graph = new WorkGraphBuilder ( true ) . build ( assembly . artifacts ) ;
62
+ const graph = new WorkGraphBuilder ( mockMsg , true ) . build ( assembly . artifacts ) ;
57
63
58
64
expect ( graph . node ( 'publish-F1-add54bdbcb' ) ) . toEqual ( expect . objectContaining ( {
59
65
type : 'asset-publish' ,
@@ -62,7 +68,7 @@ describe('with some stacks and assets', () => {
62
68
} ) ;
63
69
64
70
test ( 'with prebuild off, asset building inherits dependencies from their parent stack' , ( ) => {
65
- const graph = new WorkGraphBuilder ( false ) . build ( assembly . artifacts ) ;
71
+ const graph = new WorkGraphBuilder ( mockMsg , false ) . build ( assembly . artifacts ) ;
66
72
67
73
expect ( graph . node ( 'build-F1-a533139934' ) ) . toEqual ( expect . objectContaining ( {
68
74
type : 'asset-build' ,
@@ -71,7 +77,7 @@ describe('with some stacks and assets', () => {
71
77
} ) ;
72
78
73
79
test ( 'with prebuild on, assets only have their own dependencies' , ( ) => {
74
- const graph = new WorkGraphBuilder ( true ) . build ( assembly . artifacts ) ;
80
+ const graph = new WorkGraphBuilder ( mockMsg , true ) . build ( assembly . artifacts ) ;
75
81
76
82
expect ( graph . node ( 'build-F1-a533139934' ) ) . toEqual ( expect . objectContaining ( {
77
83
type : 'asset-build' ,
@@ -90,8 +96,8 @@ test('tree metadata is ignored', async () => {
90
96
91
97
const assembly = rootBuilder . buildAssembly ( ) ;
92
98
93
- const graph = new WorkGraphBuilder ( true ) . build ( assembly . artifacts ) ;
94
- expect ( graph . ready ( ) . length ) . toEqual ( 0 ) ;
99
+ const graph = new WorkGraphBuilder ( mockMsg , true ) . build ( assembly . artifacts ) ;
100
+ expect ( ( await graph . ready ( ) ) . length ) . toEqual ( 0 ) ;
95
101
} ) ;
96
102
97
103
test ( 'can handle nested assemblies' , async ( ) => {
@@ -103,7 +109,7 @@ test('can handle nested assemblies', async () => {
103
109
const assembly = rootBuilder . buildAssembly ( ) ;
104
110
105
111
let workDone = 0 ;
106
- const graph = new WorkGraphBuilder ( true ) . build ( assembly . artifacts ) ;
112
+ const graph = new WorkGraphBuilder ( mockMsg , true ) . build ( assembly . artifacts ) ;
107
113
108
114
await graph . doParallel ( 10 , {
109
115
deployStack : async ( ) => { workDone += 1 ; } ,
@@ -126,8 +132,8 @@ test('dependencies on unselected artifacts are silently ignored', async () => {
126
132
} ) ;
127
133
128
134
const asm = rootBuilder . buildAssembly ( ) ;
129
- const graph = new WorkGraphBuilder ( true ) . build ( [ asm . getStackArtifact ( 'stackB' ) ] ) ;
130
- expect ( graph . ready ( ) [ 0 ] ) . toEqual ( expect . objectContaining ( {
135
+ const graph = new WorkGraphBuilder ( mockMsg , true ) . build ( [ asm . getStackArtifact ( 'stackB' ) ] ) ;
136
+ expect ( ( await graph . ready ( ) ) [ 0 ] ) . toEqual ( expect . objectContaining ( {
131
137
id : 'stackB' ,
132
138
dependencies : new Set ( ) ,
133
139
} ) ) ;
@@ -162,7 +168,7 @@ describe('tests that use assets', () => {
162
168
163
169
const assembly = rootBuilder . buildAssembly ( ) ;
164
170
165
- const graph = new WorkGraphBuilder ( true ) . build ( assembly . artifacts ) ;
171
+ const graph = new WorkGraphBuilder ( mockMsg , true ) . build ( assembly . artifacts ) ;
166
172
const traversal = await traverseAndRecord ( graph ) ;
167
173
168
174
expect ( traversal ) . toEqual ( [
@@ -184,7 +190,7 @@ describe('tests that use assets', () => {
184
190
addAssets ( rootBuilder , 'StackC.assets' , { files } ) ;
185
191
186
192
const assembly = rootBuilder . buildAssembly ( ) ;
187
- const graph = new WorkGraphBuilder ( true ) . build ( assembly . artifacts ) ;
193
+ const graph = new WorkGraphBuilder ( mockMsg , true ) . build ( assembly . artifacts ) ;
188
194
189
195
// THEN
190
196
expect ( graph . findCycle ( ) ) . toBeUndefined ( ) ;
@@ -224,7 +230,7 @@ describe('tests that use assets', () => {
224
230
225
231
const assembly = rootBuilder . buildAssembly ( ) ;
226
232
227
- const graph = new WorkGraphBuilder ( true ) . build ( assembly . artifacts ) ;
233
+ const graph = new WorkGraphBuilder ( mockMsg , true ) . build ( assembly . artifacts ) ;
228
234
const traversal = await traverseAndRecord ( graph ) ;
229
235
230
236
expect ( traversal ) . toEqual ( [
@@ -270,7 +276,7 @@ describe('tests that use assets', () => {
270
276
271
277
const assembly = rootBuilder . buildAssembly ( ) ;
272
278
273
- const graph = new WorkGraphBuilder ( true ) . build ( assembly . artifacts ) ;
279
+ const graph = new WorkGraphBuilder ( mockMsg , true ) . build ( assembly . artifacts ) ;
274
280
const traversal = await traverseAndRecord ( graph ) ;
275
281
276
282
expect ( traversal ) . toEqual ( [
0 commit comments