@@ -582,6 +582,72 @@ func TestSchemaMap_Diff(t *testing.T) {
582582 Err : false ,
583583 },
584584
585+ {
586+ Name : "List decode with promotion" ,
587+ Schema : map [string ]* Schema {
588+ "ports" : & Schema {
589+ Type : TypeList ,
590+ Required : true ,
591+ Elem : & Schema {Type : TypeInt },
592+ PromoteSingle : true ,
593+ },
594+ },
595+
596+ State : nil ,
597+
598+ Config : map [string ]interface {}{
599+ "ports" : "5" ,
600+ },
601+
602+ Diff : & terraform.InstanceDiff {
603+ Attributes : map [string ]* terraform.ResourceAttrDiff {
604+ "ports.#" : & terraform.ResourceAttrDiff {
605+ Old : "0" ,
606+ New : "1" ,
607+ },
608+ "ports.0" : & terraform.ResourceAttrDiff {
609+ Old : "" ,
610+ New : "5" ,
611+ },
612+ },
613+ },
614+
615+ Err : false ,
616+ },
617+
618+ {
619+ Name : "List decode with promotion with list" ,
620+ Schema : map [string ]* Schema {
621+ "ports" : & Schema {
622+ Type : TypeList ,
623+ Required : true ,
624+ Elem : & Schema {Type : TypeInt },
625+ PromoteSingle : true ,
626+ },
627+ },
628+
629+ State : nil ,
630+
631+ Config : map [string ]interface {}{
632+ "ports" : []interface {}{"5" },
633+ },
634+
635+ Diff : & terraform.InstanceDiff {
636+ Attributes : map [string ]* terraform.ResourceAttrDiff {
637+ "ports.#" : & terraform.ResourceAttrDiff {
638+ Old : "0" ,
639+ New : "1" ,
640+ },
641+ "ports.0" : & terraform.ResourceAttrDiff {
642+ Old : "" ,
643+ New : "5" ,
644+ },
645+ },
646+ },
647+
648+ Err : false ,
649+ },
650+
585651 {
586652 Schema : map [string ]* Schema {
587653 "ports" : & Schema {
@@ -3585,6 +3651,40 @@ func TestSchemaMap_Validate(t *testing.T) {
35853651 Err : true ,
35863652 },
35873653
3654+ "List with promotion" : {
3655+ Schema : map [string ]* Schema {
3656+ "ingress" : & Schema {
3657+ Type : TypeList ,
3658+ Elem : & Schema {Type : TypeInt },
3659+ PromoteSingle : true ,
3660+ Optional : true ,
3661+ },
3662+ },
3663+
3664+ Config : map [string ]interface {}{
3665+ "ingress" : "5" ,
3666+ },
3667+
3668+ Err : false ,
3669+ },
3670+
3671+ "List with promotion set as list" : {
3672+ Schema : map [string ]* Schema {
3673+ "ingress" : & Schema {
3674+ Type : TypeList ,
3675+ Elem : & Schema {Type : TypeInt },
3676+ PromoteSingle : true ,
3677+ Optional : true ,
3678+ },
3679+ },
3680+
3681+ Config : map [string ]interface {}{
3682+ "ingress" : []interface {}{"5" },
3683+ },
3684+
3685+ Err : false ,
3686+ },
3687+
35883688 "Optional sub-resource" : {
35893689 Schema : map [string ]* Schema {
35903690 "ingress" : & Schema {
0 commit comments