@@ -620,6 +620,54 @@ func TestMarshalResources(t *testing.T) {
620
620
},
621
621
false ,
622
622
},
623
+ "single resource_with_identity" : {
624
+ map [string ]* states.Resource {
625
+ "test_identity.baz" : {
626
+ Addr : addrs.AbsResource {
627
+ Resource : addrs.Resource {
628
+ Mode : addrs .ManagedResourceMode ,
629
+ Type : "test_identity" ,
630
+ Name : "bar" ,
631
+ },
632
+ },
633
+ Instances : map [addrs.InstanceKey ]* states.ResourceInstance {
634
+ addrs .NoKey : {
635
+ Current : & states.ResourceInstanceObjectSrc {
636
+ Status : states .ObjectReady ,
637
+ AttrsJSON : []byte (`{"woozles":"confuzles","foozles":"sensuzles","name":"bar"}` ),
638
+ IdentityJSON : []byte (`{"foozles":"sensuzles","name":"bar"}` ),
639
+ },
640
+ },
641
+ },
642
+ ProviderConfig : addrs.AbsProviderConfig {
643
+ Provider : addrs .NewDefaultProvider ("test" ),
644
+ Module : addrs .RootModule ,
645
+ },
646
+ },
647
+ },
648
+ testSchemas (),
649
+ []Resource {
650
+ {
651
+ Address : "test_identity.bar" ,
652
+ Mode : "managed" ,
653
+ Type : "test_identity" ,
654
+ Name : "bar" ,
655
+ Index : nil ,
656
+ ProviderName : "registry.terraform.io/hashicorp/test" ,
657
+ AttributeValues : AttributeValues {
658
+ "name" : json .RawMessage (`"bar"` ),
659
+ "foozles" : json .RawMessage (`"sensuzles"` ),
660
+ "woozles" : json .RawMessage (`"confuzles"` ),
661
+ },
662
+ SensitiveValues : json .RawMessage ("{\" foozles\" :true}" ),
663
+ IdentityValues : IdentityValues {
664
+ "name" : json .RawMessage (`"bar"` ),
665
+ "foozles" : json .RawMessage (`"sensuzles"` ),
666
+ },
667
+ },
668
+ },
669
+ false ,
670
+ },
623
671
}
624
672
625
673
for name , test := range tests {
@@ -867,6 +915,22 @@ func testSchemas() *terraform.Schemas {
867
915
},
868
916
},
869
917
},
918
+ "test_identity" : {
919
+ Body : & configschema.Block {
920
+ Attributes : map [string ]* configschema.Attribute {
921
+ "name" : {Type : cty .String , Required : true },
922
+ "woozles" : {Type : cty .String , Optional : true , Computed : true },
923
+ "foozles" : {Type : cty .String , Optional : true , Sensitive : true },
924
+ },
925
+ },
926
+ Identity : & configschema.Object {
927
+ Attributes : map [string ]* configschema.Attribute {
928
+ "name" : {Type : cty .String , Required : true },
929
+ "foozles" : {Type : cty .String , Optional : true },
930
+ },
931
+ Nesting : configschema .NestingSingle ,
932
+ },
933
+ },
870
934
},
871
935
},
872
936
},
0 commit comments