extend gcs module tests to cover new variables
This commit is contained in:
parent
9e32b32b3d
commit
120e1be1d9
|
@ -56,6 +56,15 @@ variable "location" {
|
|||
default = "EU"
|
||||
}
|
||||
|
||||
variable "logging_config" {
|
||||
description = "Per-bucket logging."
|
||||
type = map(object({
|
||||
log_bucket = string
|
||||
log_object_prefix = string
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "names" {
|
||||
description = "Bucket name suffixes."
|
||||
type = list(string)
|
||||
|
@ -72,6 +81,15 @@ variable "project_id" {
|
|||
type = string
|
||||
}
|
||||
|
||||
variable "retention_policies" {
|
||||
description = "Per-bucket retention policy."
|
||||
type = map(object({
|
||||
retention_period = number
|
||||
is_locked = bool
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "storage_class" {
|
||||
description = "Bucket storage class."
|
||||
type = string
|
||||
|
@ -83,21 +101,3 @@ variable "versioning" {
|
|||
type = map(bool)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "retention_policies" {
|
||||
description = "Per-bucket retention policy."
|
||||
type = map(object({
|
||||
retention_period = number
|
||||
is_locked = bool
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "logging_config" {
|
||||
description = "Per-bucket logging."
|
||||
type = map(object({
|
||||
log_bucket = string
|
||||
log_object_prefix = string
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
module "test" {
|
||||
source = "../../../../modules/gcs"
|
||||
project_id = "my-project"
|
||||
names = ["bucket-a", "bucket-b"]
|
||||
prefix = var.prefix
|
||||
bucket_policy_only = var.bucket_policy_only
|
||||
force_destroy = var.force_destroy
|
||||
iam_members = var.iam_members
|
||||
iam_roles = var.iam_roles
|
||||
labels = var.labels
|
||||
bucket_policy_only = var.bucket_policy_only
|
||||
force_destroy = var.force_destroy
|
||||
logging_config = var.logging_config
|
||||
names = ["bucket-a", "bucket-b"]
|
||||
prefix = var.prefix
|
||||
retention_policies = var.retention_policies
|
||||
versioning = var.versioning
|
||||
}
|
||||
|
|
|
@ -39,11 +39,36 @@ variable "labels" {
|
|||
default = { environment = "test" }
|
||||
}
|
||||
|
||||
variable "logging_config" {
|
||||
type = map(object({
|
||||
log_bucket = string
|
||||
log_object_prefix = string
|
||||
}))
|
||||
default = {
|
||||
bucket-a = { log_bucket = "foo", log_object_prefix = null }
|
||||
}
|
||||
}
|
||||
|
||||
variable "prefix" {
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "project_id" {
|
||||
type = string
|
||||
default = "my-project"
|
||||
}
|
||||
|
||||
variable "retention_policies" {
|
||||
type = map(object({
|
||||
retention_period = number
|
||||
is_locked = bool
|
||||
}))
|
||||
default = {
|
||||
bucket-b = { retention_period = 5, is_locked = false }
|
||||
}
|
||||
}
|
||||
|
||||
variable "storage_class" {
|
||||
type = string
|
||||
default = "MULTI_REGIONAL"
|
||||
|
|
|
@ -55,6 +55,18 @@ def test_map_values(plan_runner):
|
|||
assert versioning == {
|
||||
'bucket-a': [{'enabled': True}], 'bucket-b': [{'enabled': False}]
|
||||
}
|
||||
logging_config = dict((r['values']['name'], r['values']['logging'])
|
||||
for r in resources)
|
||||
assert logging_config == {
|
||||
'bucket-a': [{'log_bucket': 'foo'}],
|
||||
'bucket-b': []
|
||||
}
|
||||
retention_policies = dict((r['values']['name'], r['values']['retention_policy'])
|
||||
for r in resources)
|
||||
assert retention_policies == {
|
||||
'bucket-a': [],
|
||||
'bucket-b': [{'is_locked': False, 'retention_period': 5}]
|
||||
}
|
||||
for r in resources:
|
||||
assert r['values']['labels'] == {
|
||||
'environment': 'test', 'location': 'eu',
|
||||
|
|
Loading…
Reference in New Issue