test: add project display_text compatibility and import coverage - #335
test: add project display_text compatibility and import coverage#335dheeraj12347 wants to merge 2 commits into
Conversation
|
Hi @sudo87 and @DaanHoogland , I’ve added a follow-up contribution in PR #335 for the cloudstack_project display_text migration. I focused on validating the compatibility behavior introduced by the new display_text field: Added acceptance coverage for configurations using display_text. The follow-up changes are in commit 37ebc48 on the PR. I’d appreciate your review and any feedback on whether you’d prefer the import compatibility handling or test structure to be adjusted further. |
37ebc48 to
b300069
Compare
|
Hi @sudo87 @DaanHoogland , since PR #332 has now been merged, I’ve followed up with PR #335 to add acceptance coverage for the display_text compatibility changes introduced there. I’ve added coverage for: display_text configuration I also cleaned up the branch so PR #335 is now based on the current main and contains only the follow-up changes in a single commit. The complete cloudstack_project acceptance suite passes locally (11/11), and git diff --check is clean. The updated PR is pushed and ready for review. Please let me know if you’d like me to adjust anything in the test structure or compatibility handling. |
| _, displaytextOk := d.GetOk("displaytext") | ||
| _, displayTextOk := d.GetOk("display_text") | ||
|
|
||
| switch { | ||
| case displaytextOk && !displayTextOk: | ||
| d.Set("displaytext", project.Displaytext) | ||
| case displayTextOk: | ||
| d.Set("display_text", project.Displaytext) | ||
| default: | ||
| d.Set("displaytext", project.Displaytext) | ||
| } |
There was a problem hiding this comment.
| _, displaytextOk := d.GetOk("displaytext") | |
| _, displayTextOk := d.GetOk("display_text") | |
| switch { | |
| case displaytextOk && !displayTextOk: | |
| d.Set("displaytext", project.Displaytext) | |
| case displayTextOk: | |
| d.Set("display_text", project.Displaytext) | |
| default: | |
| d.Set("displaytext", project.Displaytext) | |
| } | |
| _, legacyFieldConfigured := d.GetOk("displaytext") | |
| _, newFieldConfigured := d.GetOk("display_text") | |
| if legacyFieldConfigured { | |
| d.Set("displaytext", project.Displaytext) | |
| } | |
| if newFieldConfigured { | |
| d.Set("display_text", project.Displaytext) | |
| } |
There was a problem hiding this comment.
| ImportState: true, | |
| ImportStateVerify: true, | |
| ImportStateVerifyIgnore: []string{"displaytext", "display_text"} |
b300069 to
8da2248
Compare
|
Hi @sudo87 , thanks for the suggestions. I’ve incorporated both changes:
I re-ran the complete The updated changes have been pushed to the PR for review. |
kiranchavala
left a comment
There was a problem hiding this comment.
LGTM tested manually
resource "cloudstack_project" "foo" {
name = "manual-test-project"
display_text = "Manual Test1"
}
terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated
with the following symbols:
+ create
Terraform will perform the following actions:
# cloudstack_project.foo will be created
+ resource "cloudstack_project" "foo" {
+ display_text = "Manual Test1"
+ displaytext = (known after apply)
+ domain = (known after apply)
+ id = (known after apply)
+ name = "manual-test-project"
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
cloudstack_project.foo: Creating...
cloudstack_project.foo: Creation complete after 2s [id=90e055cf-ac89-4003-8442-ccb390b0c964]
change the name to displaytext
resource "cloudstack_project" "foo" {
name = "manual-test-project"
displaytext = "Manual Test2"
}
╰─ terraform apply
cloudstack_project.foo: Refreshing state... [id=90e055cf-ac89-4003-8442-ccb390b0c964]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated
with the following symbols:
~ update in-place
Terraform will perform the following actions:
# cloudstack_project.foo will be updated in-place
~ resource "cloudstack_project" "foo" {
+ displaytext = "Manual Test2"
id = "90e055cf-ac89-4003-8442-ccb390b0c964"
name = "manual-test-project"
# (2 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
╷
│ Warning: Argument is deprecated
│
│ with cloudstack_project.foo,
│ on main.tf line 12, in resource "cloudstack_project" "foo":
│ 12: displaytext = "Manual Test2"
│
│ use display_text instead
│
│ (and one more similar warning elsewhere)
╵
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
cloudstack_project.foo: Modifying... [id=90e055cf-ac89-4003-8442-ccb390b0c964]
cloudstack_project.foo: Modifications complete after 2s [id=90e055cf-ac89-4003-8442-ccb390b0c964]
╷
│ Warning: Argument is deprecated
│
│ with cloudstack_project.foo,
│ on main.tf line 12, in resource "cloudstack_project" "foo":
│ 12: displaytext = "Manual Test2"
│
│ use display_text instead
╵
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
Summary
Add acceptance coverage for the
cloudstack_projectdisplay_textmigration and verify compatibility with the deprecateddisplaytextfield.Changes
display_text.displaytexttodisplay_text.Read()state handling so only the configured display-text field is refreshed.displaytextanddisplay_textduring import verification.Validation
The complete
cloudstack_projectacceptance test suite passes locally:TestAccCloudStackProject_basicTestAccCloudStackProject_displayTextTestAccCloudStackProject_displayTextMigrationTestAccCloudStackProject_updateTestAccCloudStackProject_importTestAccCloudStackProject_accountTestAccCloudStackProject_updateAccountTestAccCloudStackProject_emptyDisplayTextTestAccCloudStackProject_updateUseridTestAccCloudStackProject_updateAccountidTestAccCloudStackProject_listResult: 11/11 passing
Also verified with: