@@ -43,13 +43,13 @@ func (a attributePathStepperTestSlice) ApplyTerraform5AttributePathStep(step Att
43
43
func TestWalkAttributePath (t * testing.T ) {
44
44
t .Parallel ()
45
45
type testCase struct {
46
- value interface {}
46
+ in interface {}
47
47
path * AttributePath
48
48
expected interface {}
49
49
}
50
50
tests := map [string ]testCase {
51
51
"msi-root" : {
52
- value : map [string ]interface {}{
52
+ in : map [string ]interface {}{
53
53
"a" : map [string ]interface {}{
54
54
"red" : true ,
55
55
"blue" : 123 ,
@@ -70,7 +70,7 @@ func TestWalkAttributePath(t *testing.T) {
70
70
},
71
71
},
72
72
"msi-full" : {
73
- value : map [string ]interface {}{
73
+ in : map [string ]interface {}{
74
74
"a" : map [string ]interface {}{
75
75
"red" : true ,
76
76
"blue" : 123 ,
@@ -88,8 +88,180 @@ func TestWalkAttributePath(t *testing.T) {
88
88
},
89
89
expected : true ,
90
90
},
91
+ "Object-AttributeName-Bool" : {
92
+ in : Object {
93
+ AttributeTypes : map [string ]Type {
94
+ "other" : String ,
95
+ "test" : Bool ,
96
+ },
97
+ },
98
+ path : & AttributePath {
99
+ steps : []AttributePathStep {
100
+ AttributeName ("test" ),
101
+ },
102
+ },
103
+ expected : Bool ,
104
+ },
105
+ "Object-AttributeName-DynamicPseudoType" : {
106
+ in : Object {
107
+ AttributeTypes : map [string ]Type {
108
+ "other" : Bool ,
109
+ "test" : DynamicPseudoType ,
110
+ },
111
+ },
112
+ path : & AttributePath {
113
+ steps : []AttributePathStep {
114
+ AttributeName ("test" ),
115
+ },
116
+ },
117
+ expected : DynamicPseudoType ,
118
+ },
119
+ "Object-AttributeName-List" : {
120
+ in : Object {
121
+ AttributeTypes : map [string ]Type {
122
+ "other" : Bool ,
123
+ "test" : List {ElementType : String },
124
+ },
125
+ },
126
+ path : & AttributePath {
127
+ steps : []AttributePathStep {
128
+ AttributeName ("test" ),
129
+ },
130
+ },
131
+ expected : List {ElementType : String },
132
+ },
133
+ "Object-AttributeName-List-ElementKeyInt" : {
134
+ in : Object {
135
+ AttributeTypes : map [string ]Type {
136
+ "other" : Bool ,
137
+ "test" : List {ElementType : String },
138
+ },
139
+ },
140
+ path : & AttributePath {
141
+ steps : []AttributePathStep {
142
+ AttributeName ("test" ),
143
+ ElementKeyInt (0 ),
144
+ },
145
+ },
146
+ expected : String ,
147
+ },
148
+ "Object-AttributeName-Map" : {
149
+ in : Object {
150
+ AttributeTypes : map [string ]Type {
151
+ "other" : Bool ,
152
+ "test" : Map {ElementType : String },
153
+ },
154
+ },
155
+ path : & AttributePath {
156
+ steps : []AttributePathStep {
157
+ AttributeName ("test" ),
158
+ },
159
+ },
160
+ expected : Map {ElementType : String },
161
+ },
162
+ "Object-AttributeName-Map-ElementKeyString" : {
163
+ in : Object {
164
+ AttributeTypes : map [string ]Type {
165
+ "other" : Bool ,
166
+ "test" : Map {ElementType : String },
167
+ },
168
+ },
169
+ path : & AttributePath {
170
+ steps : []AttributePathStep {
171
+ AttributeName ("test" ),
172
+ ElementKeyString ("sub-test" ),
173
+ },
174
+ },
175
+ expected : String ,
176
+ },
177
+ "Object-AttributeName-Number" : {
178
+ in : Object {
179
+ AttributeTypes : map [string ]Type {
180
+ "other" : Bool ,
181
+ "test" : Number ,
182
+ },
183
+ },
184
+ path : & AttributePath {
185
+ steps : []AttributePathStep {
186
+ AttributeName ("test" ),
187
+ },
188
+ },
189
+ expected : Number ,
190
+ },
191
+ "Object-AttributeName-Set" : {
192
+ in : Object {
193
+ AttributeTypes : map [string ]Type {
194
+ "other" : Bool ,
195
+ "test" : Set {ElementType : String },
196
+ },
197
+ },
198
+ path : & AttributePath {
199
+ steps : []AttributePathStep {
200
+ AttributeName ("test" ),
201
+ },
202
+ },
203
+ expected : Set {ElementType : String },
204
+ },
205
+ "Object-AttributeName-Set-ElementKeyValue" : {
206
+ in : Object {
207
+ AttributeTypes : map [string ]Type {
208
+ "other" : Bool ,
209
+ "test" : Set {ElementType : String },
210
+ },
211
+ },
212
+ path : & AttributePath {
213
+ steps : []AttributePathStep {
214
+ AttributeName ("test" ),
215
+ ElementKeyValue (NewValue (String , "sub-test" )),
216
+ },
217
+ },
218
+ expected : String ,
219
+ },
220
+ "Object-AttributeName-String" : {
221
+ in : Object {
222
+ AttributeTypes : map [string ]Type {
223
+ "other" : Bool ,
224
+ "test" : String ,
225
+ },
226
+ },
227
+ path : & AttributePath {
228
+ steps : []AttributePathStep {
229
+ AttributeName ("test" ),
230
+ },
231
+ },
232
+ expected : String ,
233
+ },
234
+ "Object-AttributeName-Tuple" : {
235
+ in : Object {
236
+ AttributeTypes : map [string ]Type {
237
+ "other" : Bool ,
238
+ "test" : Tuple {ElementTypes : []Type {Bool , String }},
239
+ },
240
+ },
241
+ path : & AttributePath {
242
+ steps : []AttributePathStep {
243
+ AttributeName ("test" ),
244
+ },
245
+ },
246
+ expected : Tuple {ElementTypes : []Type {Bool , String }},
247
+ },
248
+ "Object-AttributeName-Tuple-ElementKeyInt" : {
249
+ in : Object {
250
+ AttributeTypes : map [string ]Type {
251
+ "other" : Bool ,
252
+ "test" : Tuple {ElementTypes : []Type {Bool , String }},
253
+ },
254
+ },
255
+ path : & AttributePath {
256
+ steps : []AttributePathStep {
257
+ AttributeName ("test" ),
258
+ ElementKeyInt (1 ),
259
+ },
260
+ },
261
+ expected : String ,
262
+ },
91
263
"slice-interface-root" : {
92
- value : []interface {}{
264
+ in : []interface {}{
93
265
map [string ]interface {}{
94
266
"a" : true ,
95
267
"b" : 123 ,
@@ -119,7 +291,7 @@ func TestWalkAttributePath(t *testing.T) {
119
291
},
120
292
},
121
293
"slice-interface-full" : {
122
- value : []interface {}{
294
+ in : []interface {}{
123
295
map [string ]interface {}{
124
296
"a" : true ,
125
297
"b" : 123 ,
@@ -144,7 +316,7 @@ func TestWalkAttributePath(t *testing.T) {
144
316
expected : "hello world" ,
145
317
},
146
318
"attributepathstepper" : {
147
- value : []interface {}{
319
+ in : []interface {}{
148
320
attributePathStepperTestStruct {
149
321
Name : "terraform" ,
150
322
Colors : []string {
@@ -173,7 +345,7 @@ func TestWalkAttributePath(t *testing.T) {
173
345
name , test := name , test
174
346
t .Run (name , func (t * testing.T ) {
175
347
t .Parallel ()
176
- result , remaining , err := WalkAttributePath (test .value , test .path )
348
+ result , remaining , err := WalkAttributePath (test .in , test .path )
177
349
if err != nil {
178
350
t .Fatalf ("error walking attribute path, %v still remains in the path: %s" , remaining , err )
179
351
}
0 commit comments