Updated README.md. Added tests.

This commit is contained in:
Simone Ruffilli
2021-12-07 09:35:24 +01:00
parent 04cf75d446
commit 8a2ad25a45
5 changed files with 61 additions and 3 deletions

View File

@@ -0,0 +1,9 @@
region: europe-west1
description: Sample description
ip_cidr_range: 10.128.0.0/24
private_ip_google_access: false
iam_users: ["foobar@example.com"]
iam_groups: ["lorem@example.com"]
iam_service_accounts: ["foobar@project-id.iam.gserviceaccount.com"]
secondary_ip_range:
secondary-range-a: 192.168.128.0/24

View File

@@ -31,4 +31,5 @@ module "test" {
subnet_private_access = var.subnet_private_access
auto_create_subnetworks = var.auto_create_subnetworks
private_service_networking_range = var.private_service_networking_range
data_folder = var.data_folder
}

View File

@@ -125,3 +125,9 @@ variable "private_service_networking_range" {
type = string
default = null
}
variable "data_folder" {
description = "An optional folder containing the subnet configurations in YaML format."
type = string
default = null
}

View File

@@ -29,6 +29,19 @@ _VAR_SUBNETS = (
']'
)
_VAR_DATA_FOLDER = "data"
def test_subnet_factory(plan_runner):
"Test subnet factory."
_, resources = plan_runner(FIXTURES_DIR, data_folder=_VAR_DATA_FOLDER)
assert len(resources) == 3
subnets = [r['values']
for r in resources if r['type'] == 'google_compute_subnetwork']
assert set(s['name'] for s in subnets) == set(
['factory-subnet'])
assert set(len(s['secondary_ip_range']) for s in subnets) == set([1])
def test_subnets_simple(plan_runner):
"Test subnets variable."
@@ -58,9 +71,9 @@ def test_subnet_log_configs(plan_runner):
for r in resources:
if r['type'] != 'google_compute_subnetwork':
continue
flow_logs[r['values']['name']] = [{key: config[key] for key in config.keys()
& {'aggregation_interval', 'flow_sampling', 'metadata'}}
for config in r['values']['log_config']]
flow_logs[r['values']['name']] = [{key: config[key] for key in config.keys()
& {'aggregation_interval', 'flow_sampling', 'metadata'}}
for config in r['values']['log_config']]
assert flow_logs == {
# enable, override one default option
'a': [{