|
| 1 | +# rhcs_hcp_default_ingress count follows var.wait_for_create_complete only (see main.tf). |
| 2 | +# Driving count from resource attributes that can be null after import caused: |
| 3 | +# "The condition value is null. Conditions must either be true or false." |
| 4 | +# These plan-mode runs assert both branches: count 1 when true, count 0 when false. |
| 5 | + |
| 6 | +mock_provider "aws" { |
| 7 | + alias = "default" |
| 8 | + |
| 9 | + mock_data "aws_partition" { |
| 10 | + defaults = { |
| 11 | + dns_suffix = "amazonaws.com" |
| 12 | + id = "aws" |
| 13 | + partition = "aws" |
| 14 | + reverse_dns_prefix = "amazonaws.com" |
| 15 | + } |
| 16 | + } |
| 17 | + |
| 18 | + mock_data "aws_subnet" { |
| 19 | + defaults = { |
| 20 | + availability_zone = "us-east-1a" |
| 21 | + id = "subnet-fake12345" |
| 22 | + } |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +mock_provider "rhcs" { |
| 27 | + alias = "import_sim" |
| 28 | + override_during = plan |
| 29 | + |
| 30 | + # Partial cluster state simulation for plan (not used for default_ingress count). |
| 31 | + mock_resource "rhcs_cluster_rosa_hcp" { |
| 32 | + defaults = { |
| 33 | + id = "rhcs-fake-cluster-id" |
| 34 | + wait_for_create_complete = null |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + mock_resource "rhcs_hcp_default_ingress" { |
| 39 | + defaults = {} |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +variables { |
| 44 | + cluster_name = "existing-cluster" |
| 45 | + openshift_version = "4.15.0" |
| 46 | + oidc_config_id = "00000000000000000000000000000000" |
| 47 | + operator_role_prefix = "test-operator-prefix" |
| 48 | + account_role_prefix = "test-account-prefix" |
| 49 | + aws_subnet_ids = ["subnet-fake12345"] |
| 50 | + aws_availability_zones = ["us-east-1a"] |
| 51 | + aws_account_id = "123456789012" |
| 52 | + aws_account_arn = "arn:aws:iam::123456789012:root" |
| 53 | + aws_region = "us-east-1" |
| 54 | + wait_for_create_complete = true |
| 55 | +} |
| 56 | + |
| 57 | +run "plan_default_ingress_count_when_wait_for_create_complete_true" { |
| 58 | + command = plan |
| 59 | + |
| 60 | + providers = { |
| 61 | + aws = aws.default |
| 62 | + rhcs = rhcs.import_sim |
| 63 | + } |
| 64 | + |
| 65 | + assert { |
| 66 | + condition = length(rhcs_hcp_default_ingress.default_ingress) == 1 |
| 67 | + error_message = "rhcs_hcp_default_ingress.default_ingress must have count 1 when var.wait_for_create_complete is true." |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +run "plan_default_ingress_count_when_wait_for_create_complete_false" { |
| 72 | + command = plan |
| 73 | + |
| 74 | + providers = { |
| 75 | + aws = aws.default |
| 76 | + rhcs = rhcs.import_sim |
| 77 | + } |
| 78 | + |
| 79 | + variables { |
| 80 | + wait_for_create_complete = false |
| 81 | + } |
| 82 | + |
| 83 | + assert { |
| 84 | + condition = length(rhcs_hcp_default_ingress.default_ingress) == 0 |
| 85 | + error_message = "rhcs_hcp_default_ingress.default_ingress must have count 0 when var.wait_for_create_complete is false." |
| 86 | + } |
| 87 | +} |
0 commit comments