Skip to content

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

Open
dheeraj12347 wants to merge 1 commit into
apache:mainfrom
dheeraj12347:investigate-pr-332
Open

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

Conversation

@dheeraj12347

Copy link
Copy Markdown

Summary

Add acceptance coverage for the cloudstack_project display_text migration and fix an import-state compatibility issue discovered during testing.

The existing resource supports the new snake_case display_text field while retaining the deprecated displaytext field for backwards compatibility. These changes exercise both paths against the CloudStack simulator and verify that existing project behavior remains intact.

Changes

  • Add an acceptance test for projects configured with display_text.
  • Add acceptance coverage for precedence when both display_text and deprecated displaytext are configured.
  • Verify updating the effective display_text value.
  • Fix Read() state handling for cases where neither display-text field is present in configuration, such as resource import.
  • Preserve the legacy displaytext state representation in that case to avoid an import-state mismatch.

Validation

The complete cloudstack_project acceptance test suite passes:

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

Result: 11/11 passing

Also verified with:

make test
git diff --check

Both pass successfully.

Regression found during validation

The initial full acceptance run exposed an import-state mismatch where the imported resource contained displaytext while the provider read populated display_text.

The Read() logic was adjusted to distinguish between:

  1. legacy displaytext configurations,
  2. new display_text configurations, and
  3. imported resources where neither field is configured.

The import acceptance test now passes without affecting the existing project acceptance tests.

@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.

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.

1 participant