-
Notifications
You must be signed in to change notification settings - Fork 2
Add Local Provider Testing Support for Migration E2E Tests & improve integration tests #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
213 changes: 7 additions & 206 deletions
213
integration/v4_to_v5/testdata/logpull_retention/expected/logpull_retention.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,218 +1,19 @@ | ||
| # Integration Test for cloudflare_logpull_retention v4 → v5 Migration | ||
| # This file tests ALL Terraform patterns as required by subtask 08 | ||
|
|
||
| # ============================================================================ | ||
| # Pattern Group 1: Variables & Locals (Required by Subtask 08) | ||
| # ============================================================================ | ||
|
|
||
| variable "cloudflare_account_id" { | ||
| description = "Cloudflare account ID" | ||
| type = string | ||
| } | ||
| # Simplified to single resource since logpull_retention is a zone-level setting | ||
|
|
||
| variable "cloudflare_zone_id" { | ||
| description = "Cloudflare zone ID" | ||
| type = string | ||
| } | ||
|
|
||
| locals { | ||
| common_zone = var.cloudflare_zone_id | ||
| name_prefix = "test-integration" | ||
| tags = ["test", "migration", "v4_to_v5"] | ||
| enable_feature = true | ||
| enable_test = false | ||
| zone_count = 3 | ||
| } | ||
|
|
||
| # ============================================================================ | ||
| # Pattern Group 2: for_each with Maps (3-5 resources) | ||
| # ============================================================================ | ||
|
|
||
| resource "cloudflare_logpull_retention" "map_example" { | ||
| for_each = { | ||
| "zone1" = { | ||
| zone_id = var.cloudflare_zone_id | ||
| enabled = true | ||
| } | ||
| "zone2" = { | ||
| zone_id = var.cloudflare_zone_id | ||
| enabled = false | ||
| } | ||
| "zone3" = { | ||
| zone_id = var.cloudflare_zone_id | ||
| enabled = true | ||
| } | ||
| "zone4" = { | ||
| zone_id = var.cloudflare_zone_id | ||
| enabled = false | ||
| } | ||
| } | ||
|
|
||
| zone_id = each.value.zone_id | ||
| flag = each.value.enabled | ||
| } | ||
|
|
||
| # ============================================================================ | ||
| # Pattern Group 3: for_each with Sets (3-5 items) | ||
| # ============================================================================ | ||
|
|
||
| resource "cloudflare_logpull_retention" "set_example" { | ||
| for_each = toset([ | ||
| "alpha", | ||
| "beta", | ||
| "gamma", | ||
| "delta" | ||
| ]) | ||
|
|
||
| zone_id = var.cloudflare_zone_id | ||
| flag = each.key == "alpha" || each.key == "gamma" ? true : false | ||
| } | ||
|
|
||
| # ============================================================================ | ||
| # Pattern Group 4: count-based Resources (at least 3) | ||
| # ============================================================================ | ||
|
|
||
| resource "cloudflare_logpull_retention" "counted" { | ||
| count = 3 | ||
|
|
||
| zone_id = var.cloudflare_zone_id | ||
| flag = count.index % 2 == 0 ? true : false | ||
| } | ||
|
|
||
| # ============================================================================ | ||
| # Pattern Group 5: Conditional Creation | ||
| # ============================================================================ | ||
|
|
||
| resource "cloudflare_logpull_retention" "conditional_enabled" { | ||
| count = local.enable_feature ? 1 : 0 | ||
|
|
||
| zone_id = var.cloudflare_zone_id | ||
| flag = true | ||
| } | ||
|
|
||
| resource "cloudflare_logpull_retention" "conditional_disabled" { | ||
| count = local.enable_test ? 1 : 0 | ||
|
|
||
| zone_id = var.cloudflare_zone_id | ||
| flag = false | ||
| } | ||
|
|
||
| # ============================================================================ | ||
| # Pattern Group 6: Terraform Functions | ||
| # ============================================================================ | ||
|
|
||
| resource "cloudflare_logpull_retention" "with_functions" { | ||
| zone_id = var.cloudflare_zone_id | ||
| flag = true | ||
| } | ||
|
|
||
| resource "cloudflare_logpull_retention" "with_interpolation" { | ||
| zone_id = "${var.cloudflare_zone_id}" # String interpolation | ||
| flag = false | ||
| } | ||
|
|
||
| # ============================================================================ | ||
| # Pattern Group 7: Lifecycle Meta-Arguments | ||
| # ============================================================================ | ||
|
|
||
| resource "cloudflare_logpull_retention" "with_lifecycle" { | ||
| zone_id = var.cloudflare_zone_id | ||
|
|
||
| lifecycle { | ||
| create_before_destroy = true | ||
| } | ||
| flag = true | ||
| } | ||
|
|
||
| resource "cloudflare_logpull_retention" "with_ignore_changes" { | ||
| zone_id = local.common_zone | ||
|
|
||
| lifecycle { | ||
| ignore_changes = [flag] | ||
| } | ||
| flag = false | ||
| } | ||
|
|
||
| resource "cloudflare_logpull_retention" "with_prevent_destroy" { | ||
| zone_id = var.cloudflare_zone_id | ||
|
|
||
| lifecycle { | ||
| prevent_destroy = false # Set to false for testing | ||
| } | ||
| flag = true | ||
| } | ||
|
|
||
| # ============================================================================ | ||
| # Pattern Group 8: Edge Cases | ||
| # ============================================================================ | ||
|
|
||
| # Minimal resource (only required fields) | ||
| resource "cloudflare_logpull_retention" "minimal" { | ||
| zone_id = var.cloudflare_zone_id | ||
| flag = true | ||
| } | ||
|
|
||
| # Using locals reference | ||
| resource "cloudflare_logpull_retention" "with_local" { | ||
| zone_id = local.common_zone | ||
| flag = local.enable_feature | ||
| } | ||
|
|
||
| # Complex conditional expression | ||
| resource "cloudflare_logpull_retention" "complex_conditional" { | ||
| zone_id = var.cloudflare_zone_id | ||
| flag = local.enable_feature && !local.enable_test ? true : false | ||
| variable "cloudflare_account_id" { | ||
| description = "Cloudflare account ID" | ||
| type = string | ||
| } | ||
|
|
||
| # ============================================================================ | ||
| # Pattern Group 9: Additional Real-World Patterns | ||
| # ============================================================================ | ||
|
|
||
| # Testing enabled=true explicitly | ||
| resource "cloudflare_logpull_retention" "enabled_explicit" { | ||
| # Single logpull retention resource | ||
| # Tests the basic enabled → flag migration | ||
| resource "cloudflare_logpull_retention" "basic" { | ||
| zone_id = var.cloudflare_zone_id | ||
| flag = true | ||
| } | ||
|
|
||
| # Testing enabled=false explicitly | ||
| resource "cloudflare_logpull_retention" "disabled_explicit" { | ||
| zone_id = var.cloudflare_zone_id | ||
| flag = false | ||
| } | ||
|
|
||
| # Using ternary operator | ||
| resource "cloudflare_logpull_retention" "ternary_true" { | ||
| zone_id = var.cloudflare_zone_id | ||
| flag = 1 == 1 ? true : false | ||
| } | ||
|
|
||
| resource "cloudflare_logpull_retention" "ternary_false" { | ||
| zone_id = var.cloudflare_zone_id | ||
| flag = 1 == 2 ? true : false | ||
| } | ||
|
|
||
| # ============================================================================ | ||
| # Summary: | ||
| # - Total resource declarations: 18 | ||
| # - Total instances created: | ||
| # - map_example: 4 instances | ||
| # - set_example: 4 instances | ||
| # - counted: 3 instances | ||
| # - conditional_enabled: 1 instance | ||
| # - conditional_disabled: 0 instances (count = 0) | ||
| # - Others: 11 instances | ||
| # TOTAL: 4 + 4 + 3 + 1 + 0 + 11 = 23 instances | ||
| # | ||
| # Patterns covered: | ||
| # ✓ Variables (cloudflare_account_id, cloudflare_zone_id) | ||
| # ✓ Locals (common_zone, enable_feature, enable_test) | ||
| # ✓ for_each with maps (4 resources) | ||
| # ✓ for_each with sets using toset() (4 resources) | ||
| # ✓ count-based resources (3 resources) | ||
| # ✓ Conditional creation with ternary operator | ||
| # ✓ String interpolation | ||
| # ✓ Lifecycle meta-arguments (create_before_destroy, ignore_changes, prevent_destroy) | ||
| # ✓ Terraform functions (toset()) | ||
| # ✓ Edge cases (minimal config, complex conditionals) | ||
| # ✓ Boolean values (both true and false) | ||
| # ============================================================================ | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no point in having complex test cases for this very simple resource, so I cleaned them up