-
Notifications
You must be signed in to change notification settings - Fork 765
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
resource/github_repository_deploy_key: Trim key #132
Conversation
85d0086
to
9c01db3
Compare
oldV := "ssh-rsa AAAABB...cd+== terraform-acctest@hashicorp.com\n" | ||
newV := "ssh-rsa AAAABB...cd+==" | ||
if suppressDeployKeyDiff("test", oldV, newV, nil) { | ||
t.Fatalf("Expected %q and %q to be suppressed", oldV, newV) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean NOT suppressed in the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only real blocker for me on the PR, either the message is missing NOT
or the conditional should be negated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, the reason the test was passing is because I accidentally swapped oldV
and newV
. 🙈
Fixed now!
@@ -11,21 +13,43 @@ import ( | |||
"github.com/hashicorp/terraform/terraform" | |||
) | |||
|
|||
func TestSuppressDeployKeyDiff(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really strongly opinionated on this, but typically I do 1 validation per test and typically the function name is quite verbose, almost describing the test circumstance. What is more important though is our unit test style is consistent, so if this is consistent with everything it's all good with me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair point, I'll break it apart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we do have many unit tests (set aside acceptance tests which can have multiple steps) which have multiple test cases in them and I think it's fine? e.g. https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/validators_test.go#L12-L54
The thing which I agree needs changing though is the error message, so it's more obvious where each failure is coming from. 👍 I will fix that.
9c01db3
to
c50e02a
Compare
28d1145
to
b417dbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@@ -11,21 +13,60 @@ import ( | |||
"github.com/hashicorp/terraform/terraform" | |||
) | |||
|
|||
func TestSuppressDeployKeyDiff(t *testing.T) { | |||
testCases := []struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice table driven tests!
…epo-deploy-key resource/github_repository_deploy_key: Trim key
Fixes #69