Skip to content

Commit

Permalink
Shorten test env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnStainsby committed Dec 11, 2024
1 parent e3ce0f5 commit 49c8fdc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion postgres/database-copy-pipeline/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ locals {
copilot-environment = var.environment
}

pipeline_name = substr("${var.database_name}-${var.task.from}-to-${var.task.to}-copy-pipeline", 0, 48)
pipeline_name = "${var.database_name}-${var.task.from}-to-${var.task.to}-copy-pipeline"
region_account = "${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}"
from_account = coalesce(var.task.from_account, data.aws_caller_identity.current.account_id)
dump_role_arn = "arn:aws:iam::${local.from_account}:role/${var.application}-${var.task.from}-${var.database_name}-dump-task"
Expand Down
68 changes: 34 additions & 34 deletions postgres/tests/unit.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ override_data {

variables {
application = "test-application"
environment = "test-environment"
environment = "test-env"
name = "test-name"
vpc_name = "sandbox-postgres"
config = {
Expand All @@ -152,8 +152,8 @@ variables {
multi_az = false,
database_copy = [
{
from = "test-environment"
to = "some-other-environment"
from = "test-env"
to = "other-env"
}
]
}
Expand All @@ -164,7 +164,7 @@ run "aws_security_group_unit_test" {
command = plan

assert {
condition = aws_security_group.default.name == "test-application-test-environment-test-name"
condition = aws_security_group.default.name == "test-application-test-env-test-name"
error_message = "Invalid name for aws_security_group.default"
}

Expand All @@ -177,7 +177,7 @@ run "aws_security_group_unit_test" {
}

assert {
condition = aws_security_group.default.tags.environment == "test-environment"
condition = aws_security_group.default.tags.environment == "test-env"
error_message = "Invalid tags for aws_security_group.default copilot-environment"
}

Expand All @@ -187,7 +187,7 @@ run "aws_security_group_unit_test" {
}

assert {
condition = aws_security_group.default.tags.copilot-environment == "test-environment"
condition = aws_security_group.default.tags.copilot-environment == "test-env"
error_message = "Invalid tags for aws_security_group.default copilot-environment"
}

Expand All @@ -202,7 +202,7 @@ run "aws_db_parameter_group_unit_test" {
command = plan

assert {
condition = aws_db_parameter_group.default.name == "test-application-test-environment-test-name-postgres14"
condition = aws_db_parameter_group.default.name == "test-application-test-env-test-name-postgres14"
error_message = "Invalid name for aws_db_parameter_group.default"
}

Expand Down Expand Up @@ -232,7 +232,7 @@ run "aws_db_subnet_group_unit_test" {
command = plan

assert {
condition = aws_db_subnet_group.default.name == "test-application-test-environment-test-name"
condition = aws_db_subnet_group.default.name == "test-application-test-env-test-name"
error_message = "Invalid name for aws_db_subnet_group.default"
}

Expand All @@ -246,7 +246,7 @@ run "aws_kms_key_unit_test" {
command = plan

assert {
condition = aws_kms_key.default.description == "test-application-test-environment-test-name KMS key"
condition = aws_kms_key.default.description == "test-application-test-env-test-name KMS key"
error_message = "Invalid description for aws_kms_key.default"
}

Expand Down Expand Up @@ -278,7 +278,7 @@ run "aws_db_instance_unit_test" {
}

assert {
condition = aws_db_instance.default.db_subnet_group_name == "test-application-test-environment-test-name"
condition = aws_db_instance.default.db_subnet_group_name == "test-application-test-env-test-name"
error_message = "Invalid db_subnet_group_name for aws_db_instance.default"
}

Expand Down Expand Up @@ -416,8 +416,8 @@ run "aws_db_instance_unit_test_database_dump_created" {
version = 14,
database_copy = [
{
from = "test-environment"
to = "some-other-environment"
from = "test-env"
to = "other-env"
}
]
}
Expand All @@ -442,12 +442,12 @@ run "aws_db_instance_unit_test_database_dump_multiple_source" {
version = 14,
database_copy = [
{
from = "test-environment"
to = "some-other-environment"
from = "test-env"
to = "other-env"
},
{
from = "test-environment"
to = "some-other-environment-2"
from = "test-env"
to = "other-env-2"
}
]
}
Expand Down Expand Up @@ -477,7 +477,7 @@ run "aws_db_instance_unit_test_database_dump_not_created_if_to_env_is_prod" {
version = 14,
database_copy = [
{
from = "test-environment"
from = "test-env"
to = "some-prod-environment"
}
]
Expand All @@ -503,8 +503,8 @@ run "aws_db_instance_unit_test_database_load_created" {
version = 14,
database_copy = [
{
from = "some-other-environment"
to = "test-environment"
from = "other-env"
to = "test-env"
}
]
}
Expand All @@ -529,7 +529,7 @@ run "aws_db_instance_unit_test_database_load_not_created_if_to_env_is_prod" {
version = 14,
database_copy = [
{
from = "some-other-environment"
from = "other-env"
to = "test-prod-environment"
}
]
Expand Down Expand Up @@ -654,7 +654,7 @@ run "aws_iam_role_unit_test" {

# Test aws_iam_role.lambda-execution-role resource
assert {
condition = aws_iam_role.lambda-execution-role.name == "test-application-test-environment-test-name-lambda-role"
condition = aws_iam_role.lambda-execution-role.name == "test-application-test-env-test-name-lambda-role"
error_message = "Invalid name for aws_iam_role.lambda-execution-role"
}

Expand Down Expand Up @@ -688,7 +688,7 @@ run "aws_cloudwatch_log_rds_subscription_filter_unit_test" {
command = plan

assert {
condition = aws_cloudwatch_log_subscription_filter.rds.name == "/aws/rds/instance/test-application/test-environment/test-name/postgresql"
condition = aws_cloudwatch_log_subscription_filter.rds.name == "/aws/rds/instance/test-application/test-env/test-name/postgresql"
error_message = "Invalid name for aws_cloudwatch_log_subscription_filter.rds"
}

Expand All @@ -715,8 +715,8 @@ run "aws_lambda_function_unit_test" {
}

assert {
condition = aws_lambda_function.lambda.function_name == "test-application-test-environment-test-name-rds-create-user"
error_message = "Should be: test-application-test-environment-test-name-rds-create-user"
condition = aws_lambda_function.lambda.function_name == "test-application-test-env-test-name-rds-create-user"
error_message = "Should be: test-application-test-env-test-name-rds-create-user"
}

assert {
Expand Down Expand Up @@ -758,8 +758,8 @@ run "aws_lambda_invocation_unit_test" {

# Test aws_lambda_invocation.create-application-user resource
assert {
condition = aws_lambda_invocation.create-application-user.function_name == "test-application-test-environment-test-name-rds-create-user"
error_message = "Should be: test-application-test-environment-test-name-rds-create-user"
condition = aws_lambda_invocation.create-application-user.function_name == "test-application-test-env-test-name-rds-create-user"
error_message = "Should be: test-application-test-env-test-name-rds-create-user"
}

# Cannot test for the default on a plan
Expand All @@ -773,8 +773,8 @@ run "aws_lambda_invocation_unit_test" {

# Test aws_lambda_invocation.create-readonly-user resource
assert {
condition = aws_lambda_invocation.create-readonly-user.function_name == "test-application-test-environment-test-name-rds-create-user"
error_message = "Should be: test-application-test-environment-test-name-rds-create-user"
condition = aws_lambda_invocation.create-readonly-user.function_name == "test-application-test-env-test-name-rds-create-user"
error_message = "Should be: test-application-test-env-test-name-rds-create-user"
}

# Cannot test for the default on a plan
Expand All @@ -796,8 +796,8 @@ run "aws_ssm_parameter_master_secret_arn_unit_test" {
command = plan

assert {
condition = aws_ssm_parameter.master-secret-arn.name == "/copilot/test-application/test-environment/secrets/TEST_NAME_RDS_MASTER_ARN"
error_message = "Should be: /copilot/test-application/test-environment/secrets/TEST_NAME_RDS_MASTER_ARN"
condition = aws_ssm_parameter.master-secret-arn.name == "/copilot/test-application/test-env/secrets/TEST_NAME_RDS_MASTER_ARN"
error_message = "Should be: /copilot/test-application/test-env/secrets/TEST_NAME_RDS_MASTER_ARN"
}

assert {
Expand All @@ -814,12 +814,12 @@ run "aws_db_instance_database_copy_pipeline" {
version = 14,
database_copy = [
{
from = "test-environment"
to = "some-other-environment"
from = "test-env"
to = "other-env"
},
{
from = "some-other-environment"
to = "test-environment"
from = "other-env"
to = "test-env"
pipeline = {}
}
]
Expand Down

0 comments on commit 49c8fdc

Please sign in to comment.