@@ -309,6 +309,59 @@ func TestExpandFrameworkStringValueSet(t *testing.T) {
309
309
}
310
310
}
311
311
312
+ func TestExpandFrameworkStringyValueSet (t * testing.T ) {
313
+ t .Parallel ()
314
+
315
+ type testEnum string
316
+ var testVal1 testEnum = "testVal1"
317
+ var testVal2 testEnum = "testVal2"
318
+
319
+ type testCase struct {
320
+ input types.Set
321
+ expected itypes.Set [testEnum ]
322
+ }
323
+ tests := map [string ]testCase {
324
+ "null" : {
325
+ input : types .SetNull (types .StringType ),
326
+ expected : nil ,
327
+ },
328
+ "unknown" : {
329
+ input : types .SetUnknown (types .StringType ),
330
+ expected : nil ,
331
+ },
332
+ "two elements" : {
333
+ input : types .SetValueMust (types .StringType , []attr.Value {
334
+ types .StringValue (string (testVal1 )),
335
+ types .StringValue (string (testVal2 )),
336
+ }),
337
+ expected : []testEnum {testVal1 , testVal2 },
338
+ },
339
+ "zero elements" : {
340
+ input : types .SetValueMust (types .StringType , []attr.Value {}),
341
+ expected : []testEnum {},
342
+ },
343
+ "invalid element type" : {
344
+ input : types .SetValueMust (types .Int64Type , []attr.Value {
345
+ types .Int64Value (42 ),
346
+ }),
347
+ expected : nil ,
348
+ },
349
+ }
350
+
351
+ for name , test := range tests {
352
+ name , test := name , test
353
+ t .Run (name , func (t * testing.T ) {
354
+ t .Parallel ()
355
+
356
+ got := flex .ExpandFrameworkStringyValueSet [testEnum ](context .Background (), test .input )
357
+
358
+ if diff := cmp .Diff (got , test .expected ); diff != "" {
359
+ t .Errorf ("unexpected diff (+wanted, -got): %s" , diff )
360
+ }
361
+ })
362
+ }
363
+ }
364
+
312
365
func TestFlattenFrameworkInt32Set (t * testing.T ) {
313
366
t .Parallel ()
314
367
0 commit comments