Fix tests

This commit is contained in:
Julio Castillo 2021-03-31 10:45:35 +02:00
parent 94b1a439ee
commit 7ca2e60399
6 changed files with 37 additions and 31 deletions

View File

@ -114,7 +114,7 @@ module "folder-sink" {
no-gce-instances = "resource.type=gce_instance" no-gce-instances = "resource.type=gce_instance"
} }
} }
# tftest:modules=5:resources=11 # tftest:modules=5:resources=12
``` ```
### Hierarchical firewall policies ### Hierarchical firewall policies
@ -186,5 +186,5 @@ module "folder2" {
| folder | Folder resource. | | | folder | Folder resource. | |
| id | Folder id. | | | id | Folder id. | |
| name | Folder name. | | | name | Folder name. | |
| sink_writer_identities | Writer identities created for each sink | | | sink_writer_identities | Writer identities created for each sink. | |
<!-- END TFDOC --> <!-- END TFDOC -->

View File

@ -131,7 +131,7 @@ module "org" {
no-gce-instances = "resource.type=gce_instance" no-gce-instances = "resource.type=gce_instance"
} }
} }
# tftest:modules=5:resources=10 # tftest:modules=5:resources=11
``` ```
@ -163,5 +163,5 @@ module "org" {
| firewall_policies | Map of firewall policy resources created in the organization. | | | firewall_policies | Map of firewall policy resources created in the organization. | |
| firewall_policy_id | Map of firewall policy ids created in the organization. | | | firewall_policy_id | Map of firewall policy ids created in the organization. | |
| organization_id | Organization id dependent on module resources. | | | organization_id | Organization id dependent on module resources. | |
| sink_writer_identities | Writer identities created for each sink | | | sink_writer_identities | Writer identities created for each sink. | |
<!-- END TFDOC --> <!-- END TFDOC -->

View File

@ -146,7 +146,7 @@ module "project-host" {
no-gce-instances = "resource.type=gce_instance" no-gce-instances = "resource.type=gce_instance"
} }
} }
# tftest:modules=5:resources=11 # tftest:modules=5:resources=12
``` ```
@ -191,6 +191,6 @@ module "project-host" {
| number | Project number. | | | number | Project number. | |
| project_id | Project id. | | | project_id | Project id. | |
| service_accounts | Product robot service accounts in project. | | | service_accounts | Product robot service accounts in project. | |
| sink_writer_identities | Writer identities created for each sink | | | sink_writer_identities | Writer identities created for each sink. | |
<!-- END TFDOC --> <!-- END TFDOC -->

View File

@ -62,15 +62,16 @@ def test_sinks(plan_runner):
} }
""" """
_, resources = plan_runner(FIXTURES_DIR, logging_sinks=logging_sinks) _, resources = plan_runner(FIXTURES_DIR, logging_sinks=logging_sinks)
assert len(resources) == 8 assert len(resources) == 9
resource_types = Counter([r["type"] for r in resources]) resource_types = Counter([r["type"] for r in resources])
assert resource_types == { assert resource_types == {
"google_bigquery_dataset_iam_binding": 1,
"google_folder": 1,
"google_logging_folder_sink": 4, "google_logging_folder_sink": 4,
"google_pubsub_topic_iam_binding": 1, "google_folder": 1,
"google_storage_bucket_iam_binding": 1, "google_bigquery_dataset_iam_member": 1,
"google_project_iam_member": 1,
"google_pubsub_topic_iam_member": 1,
"google_storage_bucket_iam_member": 1,
} }
sinks = [r for r in resources if r["type"] == "google_logging_folder_sink"] sinks = [r for r in resources if r["type"] == "google_logging_folder_sink"]
@ -111,12 +112,13 @@ def test_sinks(plan_runner):
("warning", "severity=WARNING", "storage.googleapis.com/mybucket", True), ("warning", "severity=WARNING", "storage.googleapis.com/mybucket", True),
] ]
bindings = [r for r in resources if "binding" in r["type"]] bindings = [r for r in resources if "member" in r["type"]]
values = [(r["index"], r["type"], r["values"]["role"]) for r in bindings] values = [(r["index"], r["type"], r["values"]["role"]) for r in bindings]
assert sorted(values) == [ assert sorted(values) == [
("info", "google_bigquery_dataset_iam_binding", "roles/bigquery.dataEditor"), ("debug", "google_project_iam_member", "roles/logging.bucketWriter"),
("notice", "google_pubsub_topic_iam_binding", "roles/pubsub.publisher"), ("info", "google_bigquery_dataset_iam_member", "roles/bigquery.dataEditor"),
("warning", "google_storage_bucket_iam_binding", "roles/storage.objectCreator"), ("notice", "google_pubsub_topic_iam_member", "roles/pubsub.publisher"),
("warning", "google_storage_bucket_iam_member", "roles/storage.objectCreator"),
] ]
exclusions = [(r["index"], r["values"]["exclusions"]) for r in sinks] exclusions = [(r["index"], r["values"]["exclusions"]) for r in sinks]

View File

@ -62,14 +62,15 @@ def test_sinks(plan_runner):
} }
""" """
_, resources = plan_runner(FIXTURES_DIR, logging_sinks=logging_sinks) _, resources = plan_runner(FIXTURES_DIR, logging_sinks=logging_sinks)
assert len(resources) == 7 assert len(resources) == 8
resource_types = Counter([r["type"] for r in resources]) resource_types = Counter([r["type"] for r in resources])
assert resource_types == { assert resource_types == {
"google_bigquery_dataset_iam_binding": 1,
"google_logging_organization_sink": 4, "google_logging_organization_sink": 4,
"google_pubsub_topic_iam_binding": 1, "google_bigquery_dataset_iam_member": 1,
"google_storage_bucket_iam_binding": 1, "google_project_iam_member": 1,
"google_pubsub_topic_iam_member": 1,
"google_storage_bucket_iam_member": 1,
} }
sinks = [r for r in resources if r["type"] == "google_logging_organization_sink"] sinks = [r for r in resources if r["type"] == "google_logging_organization_sink"]
@ -110,12 +111,13 @@ def test_sinks(plan_runner):
("warning", "severity=WARNING", "storage.googleapis.com/mybucket", True), ("warning", "severity=WARNING", "storage.googleapis.com/mybucket", True),
] ]
bindings = [r for r in resources if "binding" in r["type"]] bindings = [r for r in resources if "member" in r["type"]]
values = [(r["index"], r["type"], r["values"]["role"]) for r in bindings] values = [(r["index"], r["type"], r["values"]["role"]) for r in bindings]
assert sorted(values) == [ assert sorted(values) == [
("info", "google_bigquery_dataset_iam_binding", "roles/bigquery.dataEditor"), ("debug", "google_project_iam_member", "roles/logging.bucketWriter"),
("notice", "google_pubsub_topic_iam_binding", "roles/pubsub.publisher"), ("info", "google_bigquery_dataset_iam_member", "roles/bigquery.dataEditor"),
("warning", "google_storage_bucket_iam_binding", "roles/storage.objectCreator"), ("notice", "google_pubsub_topic_iam_member", "roles/pubsub.publisher"),
("warning", "google_storage_bucket_iam_member", "roles/storage.objectCreator"),
] ]
exclusions = [(r["index"], r["values"]["exclusions"]) for r in sinks] exclusions = [(r["index"], r["values"]["exclusions"]) for r in sinks]

View File

@ -62,15 +62,16 @@ def test_sinks(plan_runner):
} }
""" """
_, resources = plan_runner(FIXTURES_DIR, logging_sinks=logging_sinks) _, resources = plan_runner(FIXTURES_DIR, logging_sinks=logging_sinks)
assert len(resources) == 8 assert len(resources) == 9
resource_types = Counter([r["type"] for r in resources]) resource_types = Counter([r["type"] for r in resources])
assert resource_types == { assert resource_types == {
"google_bigquery_dataset_iam_binding": 1,
"google_logging_project_sink": 4, "google_logging_project_sink": 4,
"google_bigquery_dataset_iam_member": 1,
"google_project": 1, "google_project": 1,
"google_pubsub_topic_iam_binding": 1, "google_project_iam_member": 1,
"google_storage_bucket_iam_binding": 1, "google_pubsub_topic_iam_member": 1,
"google_storage_bucket_iam_member": 1,
} }
sinks = [r for r in resources if r["type"] == "google_logging_project_sink"] sinks = [r for r in resources if r["type"] == "google_logging_project_sink"]
@ -111,12 +112,13 @@ def test_sinks(plan_runner):
("warning", "severity=WARNING", "storage.googleapis.com/mybucket", False), ("warning", "severity=WARNING", "storage.googleapis.com/mybucket", False),
] ]
bindings = [r for r in resources if "binding" in r["type"]] bindings = [r for r in resources if "member" in r["type"]]
values = [(r["index"], r["type"], r["values"]["role"]) for r in bindings] values = [(r["index"], r["type"], r["values"]["role"]) for r in bindings]
assert sorted(values) == [ assert sorted(values) == [
("info", "google_bigquery_dataset_iam_binding", "roles/bigquery.dataEditor"), ("debug", "google_project_iam_member", "roles/logging.bucketWriter"),
("notice", "google_pubsub_topic_iam_binding", "roles/pubsub.publisher"), ("info", "google_bigquery_dataset_iam_member", "roles/bigquery.dataEditor"),
("warning", "google_storage_bucket_iam_binding", "roles/storage.objectCreator"), ("notice", "google_pubsub_topic_iam_member", "roles/pubsub.publisher"),
("warning", "google_storage_bucket_iam_member", "roles/storage.objectCreator"),
] ]
exclusions = [(r["index"], r["values"]["exclusions"]) for r in sinks] exclusions = [(r["index"], r["values"]["exclusions"]) for r in sinks]