Skip to content

Commit

Permalink
internal/verify(test): add malformed old content test case
Browse files Browse the repository at this point in the history
Before:

```console
% go test -count=1 ./internal/verify/...
--- FAIL: TestSecondJSONUnlessEquivalent (0.00s)
    json_test.go:405: unexpected error with test case malformed old: parsing policy 1: parsing statement 1: 1 error(s) decoding:

        * '[0].Condition[StringLike]' expected a map, got 'slice'
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/verify     0.702s
```

After:

```console
% go test -count=1 ./internal/verify/...
ok      github.com/hashicorp/terraform-provider-aws/internal/verify     0.383s
```
  • Loading branch information
jar-b committed Oct 22, 2024
1 parent c9c1f98 commit bfc1b40
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions internal/verify/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,48 @@ func TestSecondJSONUnlessEquivalent(t *testing.T) {
newPolicy: "",
want: "",
},
{
name: "malformed old",
oldPolicy: `{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Condition" : {
"StringLike" : ["demo-prefix/"]
},
"Resource": "*"
}
]
}`,
newPolicy: `{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": "*"
}
]
}`,
want: `{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": "*"
}
]
}`,
},
}

for _, v := range testCases {
Expand Down

0 comments on commit bfc1b40

Please sign in to comment.