@@ -36,9 +36,9 @@ func init() {
3636
3737 RequireStackResource (l , err , changes )
3838
39- // Check we have the one simple resource in the snapshot, its provider, its parent component and the
40- // stack.
41- require .Len (l , snap .Resources , 4 , "expected 4 resources in snapshot" )
39+ // Check we have the two simple resources in the snapshot, their provider, the component
40+ // and the stack.
41+ require .Len (l , snap .Resources , 5 , "expected 5 resources in snapshot" )
4242
4343 stack := RequireSingleResource (l , snap .Resources , "pulumi:pulumi:Stack" )
4444 assert .Empty (l , stack .Inputs , "expected stack to have no inputs" )
@@ -57,15 +57,45 @@ func init() {
5757
5858 RequireSingleResource (l , snap .Resources , "pulumi:providers:simple" )
5959
60- simple := RequireSingleResource (l , snap .Resources , "simple:index:Resource" )
61- assert .Equal (l , "someComponent-res" , simple .URN .Name ())
62- assert .Equal (l , component .URN , simple .Parent , "expected simple resource to have component as parent" )
63-
60+ input := RequireSingleNamedResource (l , snap .Resources , "input" )
61+ assert .Equal (l , "simple:index:Resource" , input .Type .String ())
6462 want = resource .NewPropertyMapFromMap (map [string ]any {
6563 "value" : true ,
6664 })
65+ assert .Equal (l , want , input .Inputs , "expected input resource inputs to be %v" , want )
66+ assert .Equal (l , input .Inputs , input .Outputs , "expected input resource inputs and outputs to match" )
67+
68+ simple := RequireSingleNamedResource (l , snap .Resources , "someComponent-res" )
69+ assert .Equal (l , "simple:index:Resource" , simple .Type .String ())
70+ assert .Equal (l , component .URN , simple .Parent , "expected simple resource to have component as parent" )
6771 assert .Equal (l , want , simple .Inputs , "expected inputs to be %v" , want )
6872 assert .Equal (l , simple .Inputs , simple .Outputs , "expected inputs and outputs to match" )
73+
74+ // The top-level `input` resource has a literal value, so it has no dependencies.
75+ assert .Empty (l , input .Dependencies , "expected input resource to have no dependencies" )
76+ for k , deps := range input .PropertyDependencies {
77+ assert .Empty (l , deps , "expected input resource property %q to have no dependencies" , k )
78+ }
79+
80+ // The component's `input` argument is set to `input.value`, so the component must record a
81+ // dependency on the top-level `input` resource, both overall and per-property.
82+ assert .Equal (l , []resource.URN {input .URN }, component .Dependencies ,
83+ "expected component to depend on the top-level input resource" )
84+ componentInputDeps , ok := component .PropertyDependencies ["input" ]
85+ require .True (l , ok , "expected component to have property dependencies for input" )
86+ assert .Equal (l , []resource.URN {input .URN }, componentInputDeps ,
87+ "expected component.input to depend on the top-level input resource" )
88+
89+ // Inside the component, `res.value = input` flows the component's `input` config -- which
90+ // itself traces back to the top-level `input` resource -- into the child resource. The
91+ // dependency on `input` must propagate through the component boundary so the engine can
92+ // correctly order operations.
93+ assert .Contains (l , simple .Dependencies , input .URN ,
94+ "expected simple resource inside the component to depend on the top-level input resource" )
95+ simpleValueDeps , ok := simple .PropertyDependencies ["value" ]
96+ require .True (l , ok , "expected simple resource to have property dependencies for value" )
97+ assert .Contains (l , simpleValueDeps , input .URN ,
98+ "expected simple.value inside the component to depend on the top-level input resource" )
6999 },
70100 },
71101 },
0 commit comments