Skip to content

test: add project display_text compatibility and import coverage - #335

Open
dheeraj12347 wants to merge 2 commits into
apache:mainfrom
dheeraj12347:investigate-pr-332
Open

test: add project display_text compatibility and import coverage#335
dheeraj12347 wants to merge 2 commits into
apache:mainfrom
dheeraj12347:investigate-pr-332

Conversation

@dheeraj12347

@dheeraj12347 dheeraj12347 commented Sep 1, 2026

Copy link
Copy Markdown

Summary

Add acceptance coverage for the cloudstack_project display_text migration and verify compatibility with the deprecated displaytext field.

Changes

  • Add acceptance coverage for projects configured with display_text.
  • Add acceptance coverage for migration from deprecated displaytext to display_text.
  • Update Read() state handling so only the configured display-text field is refreshed.
  • Add import-state coverage while ignoring displaytext and display_text during import verification.

Validation

The complete cloudstack_project acceptance test suite passes locally:

  • TestAccCloudStackProject_basic
  • TestAccCloudStackProject_displayText
  • TestAccCloudStackProject_displayTextMigration
  • TestAccCloudStackProject_update
  • TestAccCloudStackProject_import
  • TestAccCloudStackProject_account
  • TestAccCloudStackProject_updateAccount
  • TestAccCloudStackProject_emptyDisplayText
  • TestAccCloudStackProject_updateUserid
  • TestAccCloudStackProject_updateAccountid
  • TestAccCloudStackProject_list

Result: 11/11 passing

Also verified with:

git diff --check

@dheeraj12347

Copy link
Copy Markdown
Author

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.
Added coverage for the case where both display_text and deprecated displaytext are configured, verifying that display_text takes precedence.
Added update coverage for the effective display-text value.
During the full acceptance run, I found an import-state mismatch where Read() populated display_text while an imported resource expected the legacy displaytext representation.
Adjusted the Read() state handling to distinguish between legacy configuration, new display_text configuration, and imported resources where neither field is configured.
Re-ran the complete cloudstack_project acceptance suite: all 11 tests pass.
Also verified make test and git diff --check.

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.

@dheeraj12347

Copy link
Copy Markdown
Author

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
migration from deprecated displaytext to display_text
import compatibility and the related Read() state handling

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.

Comment on lines +364 to +374
_, 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)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_, 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)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"displaytext", "display_text"}

@dheeraj12347

Copy link
Copy Markdown
Author

Hi @sudo87 , thanks for the suggestions. I’ve incorporated both changes:

  • Updated Read() to independently refresh displaytext and display_text only when the respective field is configured.
  • Added displaytext and display_text to ImportStateVerifyIgnore.

I re-ran the complete cloudstack_project acceptance suite locally, and all 11 tests pass.

The updated changes have been pushed to the PR for review.

@sudo87 sudo87 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kiranchavala kiranchavala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants