@@ -85,3 +85,84 @@ func dotNetValidator() func(t *testing.T, stack integration.RuntimeValidationSta
85
85
assert .True (t , foundRes5Child )
86
86
}
87
87
}
88
+
89
+ func TestDotNetTransforms (t * testing.T ) {
90
+ testDotnetProgram (t , & integration.ProgramTestOptions {
91
+ Dir : "transformations_remote" ,
92
+ Quick : true ,
93
+ ExtraRuntimeValidation : Validator ,
94
+ LocalProviders : []integration.LocalDependency {
95
+ {
96
+ Package : "testprovider" ,
97
+ Path : "testprovider" ,
98
+ },
99
+ },
100
+ })
101
+ }
102
+
103
+ func Validator (t * testing.T , stack integration.RuntimeValidationStackInfo ) {
104
+ randomResName := "testprovider:index:Random"
105
+ foundRes1 := false
106
+ foundRes2Child := false
107
+ foundRes3 := false
108
+ foundRes4Child := false
109
+ foundRes5 := false
110
+ for _ , res := range stack .Deployment .Resources {
111
+ // "res1" has a transformation which adds additionalSecretOutputs
112
+ if res .URN .Name () == "res1" {
113
+ foundRes1 = true
114
+ assert .Equal (t , res .Type , tokens .Type (randomResName ))
115
+ assert .Contains (t , res .AdditionalSecretOutputs , resource .PropertyKey ("result" ))
116
+ }
117
+ // "res2" has a transformation which adds additionalSecretOutputs to it's
118
+ // "child"
119
+ if res .URN .Name () == "res2-child" {
120
+ foundRes2Child = true
121
+ assert .Equal (t , res .Type , tokens .Type (randomResName ))
122
+ assert .Equal (t , res .Parent .Type (), tokens .Type ("my:component:MyComponent" ))
123
+ assert .Contains (t , res .AdditionalSecretOutputs , resource .PropertyKey ("result" ))
124
+ assert .Contains (t , res .AdditionalSecretOutputs , resource .PropertyKey ("length" ))
125
+ }
126
+ // "res3" is impacted by a global stack transformation which sets
127
+ // optionalDefault to "stackDefault"
128
+ if res .URN .Name () == "res3" {
129
+ foundRes3 = true
130
+ assert .Equal (t , res .Type , tokens .Type (randomResName ))
131
+ optionalPrefix := res .Inputs ["prefix" ]
132
+ assert .NotNil (t , optionalPrefix )
133
+ assert .Equal (t , "stackDefault" , optionalPrefix .(string ))
134
+ length := res .Inputs ["length" ]
135
+ assert .NotNil (t , length )
136
+ // length should be secret
137
+ secret , ok := length .(map [string ]interface {})
138
+ assert .True (t , ok , "length should be a secret" )
139
+ assert .Equal (t , resource .SecretSig , secret [resource .SigKey ])
140
+ assert .Contains (t , res .AdditionalSecretOutputs , resource .PropertyKey ("result" ))
141
+ }
142
+ // "res4" is impacted by two component parent transformations which set
143
+ // optionalDefault to "default1" and then "default2" and also a global stack
144
+ // transformation which sets optionalDefault to "stackDefault". The end
145
+ // result should be "stackDefault".
146
+ if res .URN .Name () == "res4-child" {
147
+ foundRes4Child = true
148
+ assert .Equal (t , res .Type , tokens .Type (randomResName ))
149
+ assert .Equal (t , res .Parent .Type (), tokens .Type ("my:component:MyComponent" ))
150
+ optionalPrefix := res .Inputs ["prefix" ]
151
+ assert .NotNil (t , optionalPrefix )
152
+ assert .Equal (t , "stackDefault" , optionalPrefix .(string ))
153
+ }
154
+ // "res5" should have mutated the length
155
+ if res .URN .Name () == "res5" {
156
+ foundRes5 = true
157
+ assert .Equal (t , res .Type , tokens .Type (randomResName ))
158
+ length := res .Inputs ["length" ]
159
+ assert .NotNil (t , length )
160
+ assert .Equal (t , 20.0 , length .(float64 ))
161
+ }
162
+ }
163
+ assert .True (t , foundRes1 )
164
+ assert .True (t , foundRes2Child )
165
+ assert .True (t , foundRes3 )
166
+ assert .True (t , foundRes4Child )
167
+ assert .True (t , foundRes5 )
168
+ }
0 commit comments