From 7cc2dd3fccc95cffd82d6ea6770e3bfbe4d8df29 Mon Sep 17 00:00:00 2001 From: tony griffin <54268925+tony-griffin@users.noreply.github.com> Date: Wed, 22 May 2024 14:39:24 +0100 Subject: [PATCH] test: Add tests for non default values for RDS (#130) --- postgres/tests/unit.tftest.hcl | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/postgres/tests/unit.tftest.hcl b/postgres/tests/unit.tftest.hcl index a62cf9fc2..f766e009b 100644 --- a/postgres/tests/unit.tftest.hcl +++ b/postgres/tests/unit.tftest.hcl @@ -274,6 +274,61 @@ run "aws_db_instance_unit_test" { # aws_db_instance.default.iops cannot be tested on a plan } +run "aws_db_instance_unit_test_set_to_non_defaults" { + command = plan + + variables { + config = { + version = 14, + deletion_protection = false, + multi_az = true, + skip_final_snapshot = true, + volume_size = 20, + iops = 3000, + instance = "db.t3.small", + storage_type = "io2" + + } + } + + # Test aws_db_instance.default resource version + assert { + condition = aws_db_instance.default.deletion_protection == false + error_message = "Should be: false" + } + + assert { + condition = aws_db_instance.default.multi_az == true + error_message = "Should be: true" + } + + assert { + condition = aws_db_instance.default.skip_final_snapshot == true + error_message = "Should be: true" + } + + assert { + condition = aws_db_instance.default.allocated_storage == 20 + error_message = "Should be: 20" + } + + assert { + condition = aws_db_instance.default.iops == 3000 + error_message = "Should be: 20" + } + + assert { + condition = aws_db_instance.default.instance_class == "db.t3.small" + error_message = "Should be: db.t3.small" + } + + assert { + condition = aws_db_instance.default.storage_type == "io2" + error_message = "Should be: io2" + } + +} + run "aws_iam_role_unit_test" { command = plan