Skip to content

Commit c9a0200

Browse files
M-IliassMaxrovr
authored andcommitted
Bug Fix to use the correct Id for updating options config resource
1 parent 9e642b7 commit c9a0200

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

internal/integrationtest/apm_config_options_test.go

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestApmConfigOptionsResource_basic(t *testing.T) {
7676
datasourceOptionsName := "data.oci_apm_config_configs.test_optionss"
7777
singularOptionsDatasourceName := "data.oci_apm_config_config.test_options"
7878

79-
var resId string
79+
var resId, resId2 string
8080
// Save TF content to create resource with optional properties. This has to be exactly the same as the config part in the "create with optionals" step in the test.
8181
acctest.SaveConfigContent(config+compartmentIdVariableStr+ApmConfigConfigResourceDependencies+
8282
acctest.GenerateResourceFromRepresentationMap("oci_apm_config_config", "test_options", acctest.Optional, acctest.Create, configOptionsRepresentation), "apmconfig", "config", t)
@@ -140,11 +140,37 @@ func TestApmConfigOptionsResource_basic(t *testing.T) {
140140
},
141141
),
142142
},
143-
// Step 4: delete Options before next create
143+
// Step 4: verify updates to Options updatable parameters
144+
{
145+
Config: config + compartmentIdVariableStr + ApmConfigConfigResourceDependencies +
146+
acctest.GenerateResourceFromRepresentationMap("oci_apm_config_config", "test_options", acctest.Optional, acctest.Update, configOptionsRepresentation),
147+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
148+
resource.TestCheckResourceAttrSet(optionsResourceName, "apm_domain_id"),
149+
resource.TestCheckResourceAttrSet(optionsResourceName, "id"),
150+
resource.TestCheckResourceAttr(optionsResourceName, "config_type", configTypeOptions),
151+
resource.TestCheckResourceAttr(optionsResourceName, "display_name", "displayName2"),
152+
resource.TestCheckResourceAttr(optionsResourceName, "group", "group2"),
153+
resource.TestCheckResourceAttrSet(optionsResourceName, "options"),
154+
resource.TestCheckResourceAttr(optionsResourceName, "freeform_tags.%", "1"),
155+
resource.TestCheckResourceAttr(optionsResourceName, "defined_tags.%", "1"),
156+
resource.TestCheckResourceAttrSet(optionsResourceName, "created_by"),
157+
resource.TestCheckResourceAttrSet(optionsResourceName, "updated_by"),
158+
resource.TestCheckResourceAttrSet(optionsResourceName, "etag"),
159+
160+
func(s *terraform.State) (err error) {
161+
resId2, err = acctest.FromInstanceState(s, optionsResourceName, "id")
162+
if resId != resId2 {
163+
return fmt.Errorf("Resource recreated when it was supposed to be updated.")
164+
}
165+
return err
166+
},
167+
),
168+
},
169+
// Step 5: delete Options before next create
144170
{
145171
Config: config + compartmentIdVariableStr + ApmConfigConfigResourceDependencies,
146172
},
147-
// Step 5: verify datasource
173+
// Step 6: verify datasource
148174
{
149175
Config: config +
150176
acctest.GenerateDataSourceFromRepresentationMap("oci_apm_config_configs", "test_optionss", acctest.Optional, acctest.Update, configOptionsDataSourceRepresentation) +
@@ -159,7 +185,7 @@ func TestApmConfigOptionsResource_basic(t *testing.T) {
159185
resource.TestCheckResourceAttr(datasourceOptionsName, "config_collection.0.items.#", "1"),
160186
),
161187
},
162-
// Step 6: verify singular datasource
188+
// Step 7: verify singular datasource
163189
{
164190
Config: config +
165191
acctest.GenerateDataSourceFromRepresentationMap("oci_apm_config_config", "test_options", acctest.Required, acctest.Create, configOptionsSingularDataSourceRepresentation) +
@@ -179,7 +205,7 @@ func TestApmConfigOptionsResource_basic(t *testing.T) {
179205
resource.TestCheckResourceAttrSet(singularOptionsDatasourceName, "updated_by"),
180206
),
181207
},
182-
// Step 7 verify resource import
208+
// Step 8 verify resource import
183209
{
184210
Config: config + ConfigOptionsRequiredOnlyResource,
185211
ImportState: true,

internal/service/apm_config/apm_config_config_resource.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,8 +1299,6 @@ func (s *ApmConfigConfigResourceCrud) populateTopLevelPolymorphicUpdateConfigReq
12991299
tmp := apmDomainId.(string)
13001300
request.ApmDomainId = &tmp
13011301
}
1302-
tmp := s.D.Id()
1303-
request.ConfigId = &tmp
13041302
if definedTags, ok := s.D.GetOkExists("defined_tags"); ok {
13051303
convertedDefinedTags, err := tfresource.MapToDefinedTags(definedTags.(map[string]interface{}))
13061304
if err != nil {

0 commit comments

Comments
 (0)