@@ -29,13 +29,40 @@ var (
2929 "priority" : Representation {repType : Required , create : `10` , update : `15` },
3030 }
3131
32+ drgRouteDistributionStatementRepresentation2 = map [string ]interface {}{
33+ "drg_route_distribution_id" : Representation {repType : Required , create : `${oci_core_drg_route_distribution.test_drg_route_distribution.id}` },
34+ "action" : Representation {repType : Required , create : `ACCEPT` },
35+ "match_criteria" : RepresentationGroup {Required , drgRouteDistributionStatementStatementsMatchCriteriaRepresentation2 },
36+ "priority" : Representation {repType : Required , create : `20` , update : `25` },
37+ }
38+
39+ drgRouteDistributionStatementRepresentation3 = map [string ]interface {}{
40+ "drg_route_distribution_id" : Representation {repType : Required , create : `${oci_core_drg_route_distribution.test_drg_route_distribution.id}` },
41+ "action" : Representation {repType : Required , create : `ACCEPT` },
42+ "match_criteria" : RepresentationGroup {Required , drgRouteDistributionStatementStatementsMatchCriteriaRepresentation3 },
43+ "priority" : Representation {repType : Required , create : `30` , update : `35` },
44+ }
45+
3246 drgRouteDistributionStatementStatementsMatchCriteriaRepresentation = map [string ]interface {}{
3347 "match_type" : Representation {repType : Required , create : `DRG_ATTACHMENT_TYPE` },
3448 "attachment_type" : Representation {repType : Required , create : `VCN` , update : `VIRTUAL_CIRCUIT` },
3549 }
3650
51+ drgRouteDistributionStatementStatementsMatchCriteriaRepresentation2 = map [string ]interface {}{
52+ "match_type" : Representation {repType : Required , create : `DRG_ATTACHMENT_TYPE` },
53+ "attachment_type" : Representation {repType : Required , create : `REMOTE_PEERING_CONNECTION` },
54+ }
55+
56+ drgRouteDistributionStatementStatementsMatchCriteriaRepresentation3 = map [string ]interface {}{
57+ "match_type" : Representation {repType : Required , create : `DRG_ATTACHMENT_ID` },
58+ "drg_attachment_id" : Representation {repType : Required , create : `${oci_core_drg_attachment.test_drg_attachment2.id}` },
59+ }
60+
3761 DrgRouteDistributionStatementResourceDependencies = DefinedTagsDependencies +
62+ generateResourceFromRepresentationMap ("oci_core_drg_attachment" , "test_drg_attachment2" , Required , Create , drgAttachmentRepresentation ) +
3863 generateResourceFromRepresentationMap ("oci_core_drg_route_distribution" , "test_drg_route_distribution" , Required , Create , drgRouteDistributionRepresentation ) +
64+ generateResourceFromRepresentationMap ("oci_core_vcn" , "test_vcn" , Required , Create , vcnRepresentation ) +
65+ generateResourceFromRepresentationMap ("oci_core_route_table" , "test_route_table" , Required , Create , routeTableRepresentation ) +
3966 generateResourceFromRepresentationMap ("oci_core_drg" , "test_drg" , Required , Create , drgRepresentation )
4067)
4168
@@ -51,6 +78,9 @@ func TestCoreDrgRouteDistributionStatementResource_basic(t *testing.T) {
5178
5279 resourceName := "oci_core_drg_route_distribution_statement.test_drg_route_distribution_statement"
5380 datasourceName := "data.oci_core_drg_route_distribution_statements.test_drg_route_distribution_statements"
81+ resourceName1 := "oci_core_drg_route_distribution_statement.test_drg_route_distribution_statement2"
82+ resourceName2 := "oci_core_drg_route_distribution_statement.test_drg_route_distribution_statement3"
83+ resourceName3 := "oci_core_drg_route_distribution_statement.test_drg_route_distribution_statement4"
5484
5585 var resId , resId2 string
5686 // Save TF content to create resource with only required properties. This has to be exactly the same as the config part in the create step in the test.
@@ -135,6 +165,47 @@ func TestCoreDrgRouteDistributionStatementResource_basic(t *testing.T) {
135165 ImportStateVerifyIgnore : []string {},
136166 ResourceName : resourceName ,
137167 },
168+ // delete before next create
169+ {
170+ Config : config + compartmentIdVariableStr + DrgRouteDistributionStatementResourceDependencies ,
171+ },
172+ // verify create
173+ {
174+ Config : config + compartmentIdVariableStr + DrgRouteDistributionStatementResourceDependencies +
175+ generateResourceFromRepresentationMap ("oci_core_drg_route_distribution_statement" , "test_drg_route_distribution_statement2" , Optional , Create , drgRouteDistributionStatementRepresentation ) +
176+ generateResourceFromRepresentationMap ("oci_core_drg_route_distribution_statement" , "test_drg_route_distribution_statement3" , Required , Create , drgRouteDistributionStatementRepresentation2 ) +
177+ generateResourceFromRepresentationMap ("oci_core_drg_route_distribution_statement" , "test_drg_route_distribution_statement4" , Required , Create , drgRouteDistributionStatementRepresentation3 ),
178+ Check : resource .ComposeAggregateTestCheckFunc (
179+ //check first resource
180+ resource .TestCheckResourceAttrSet (resourceName1 , "drg_route_distribution_id" ),
181+ resource .TestCheckResourceAttr (resourceName1 , "action" , "ACCEPT" ),
182+ resource .TestCheckResourceAttr (resourceName1 , "match_criteria.#" , "1" ),
183+ resource .TestCheckResourceAttr (resourceName1 , "match_criteria.0.attachment_type" , "VCN" ),
184+ resource .TestCheckResourceAttr (resourceName1 , "match_criteria.0.match_type" , "DRG_ATTACHMENT_TYPE" ),
185+ resource .TestCheckResourceAttr (resourceName1 , "priority" , "10" ),
186+ resource .TestCheckResourceAttrSet (resourceName1 , "id" ),
187+ //check second resource
188+ resource .TestCheckResourceAttrSet (resourceName2 , "drg_route_distribution_id" ),
189+ resource .TestCheckResourceAttr (resourceName2 , "action" , "ACCEPT" ),
190+ resource .TestCheckResourceAttr (resourceName2 , "match_criteria.#" , "1" ),
191+ resource .TestCheckResourceAttr (resourceName2 , "match_criteria.0.attachment_type" , "REMOTE_PEERING_CONNECTION" ),
192+ resource .TestCheckResourceAttr (resourceName2 , "match_criteria.0.match_type" , "DRG_ATTACHMENT_TYPE" ),
193+ resource .TestCheckResourceAttr (resourceName2 , "priority" , "20" ),
194+ resource .TestCheckResourceAttrSet (resourceName2 , "id" ),
195+ // check third resource
196+ resource .TestCheckResourceAttrSet (resourceName3 , "drg_route_distribution_id" ),
197+ resource .TestCheckResourceAttr (resourceName3 , "action" , "ACCEPT" ),
198+ resource .TestCheckResourceAttr (resourceName3 , "match_criteria.#" , "1" ),
199+ resource .TestCheckResourceAttrSet (resourceName3 , "match_criteria.0.drg_attachment_id" ),
200+ resource .TestCheckResourceAttr (resourceName3 , "match_criteria.0.match_type" , "DRG_ATTACHMENT_ID" ),
201+ resource .TestCheckResourceAttr (resourceName3 , "priority" , "30" ),
202+ resource .TestCheckResourceAttrSet (resourceName3 , "id" ),
203+ ),
204+ },
205+ // delete
206+ {
207+ Config : config + compartmentIdVariableStr + DrgRouteDistributionStatementResourceDependencies ,
208+ },
138209 },
139210 })
140211}
0 commit comments