Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Remove redundant assertions for defaults in S3 unit tests #240

Merged
merged 4 commits into from
Oct 3, 2024

Conversation

WillGibson
Copy link
Contributor

@WillGibson WillGibson commented Oct 2, 2024

I guess the question is, were the tests right, or was the code right?

@WillGibson WillGibson requested a review from a team October 2, 2024 08:15
@@ -1,7 +1,7 @@
variables {
vpc_name = "s3-test-vpc-name"
application = "s3-test-application"
environment = "s3-test-environment"
environment = "s3-test-environmnent"
Copy link
Contributor

@antroy-madetech antroy-madetech Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you introduced the misspelling?

s3/main.tf Outdated Show resolved Hide resolved
s3/main.tf Outdated
enable_key_rotation = false
is_enabled = true
key_usage = "ENCRYPT_DECRYPT"
customer_master_key_spec = "SYMMETRIC_DEFAULT"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all just the default values anyway. Do we need them to be explicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were coming out as null in the tests.

Maybe that's a symptom of running the tests on a plan?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is the output from the plan, it's probably better to expect null rather than setting a bunch of variables when we don't need to or it looks like we've set them deliberately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely don't want to explicitly check for null when that is not the actual expected result.

Should we even be testing for the default values on a plan if they are just coming back as null?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps not. We should obviously test things we're explicitly setting. I think setting things to the default values to make tests pass is wrong, and it will lead to people wondering why we set them to those values in the future.

@WillGibson WillGibson changed the title test: Fix failing S3 unit tests test: Remove redundant assertions for defaults in S3 unit tests Oct 3, 2024
@WillGibson WillGibson merged commit d9a2ad4 into main Oct 3, 2024
11 checks passed
@WillGibson WillGibson deleted the Fix-failing-s3-tests branch October 3, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants