Skip to content

Commit

Permalink
Use a raw JSON string as a test data for easy testing
Browse files Browse the repository at this point in the history
  • Loading branch information
minamijoyo committed Apr 26, 2022
1 parent 60c3127 commit 252b08d
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions migration/schema/aws/s3_test.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
package aws

import (
"encoding/json"
"testing"

"github.com/minamijoyo/tfedit/migration/schema"
)

func TestImportIDFuncAWSS3BucketACL(t *testing.T) {
cases := []struct {
desc string
r schema.Resource
want string
desc string
resource string
want string
}{
{
desc: "acl",
r: map[string]interface{}{
"acl": "private",
"bucket": "tfedit-test",
"expected_bucket_owner": nil,
},
resource: `
{
"acl": "private",
"bucket": "tfedit-test",
"expected_bucket_owner": null
}
`,
want: "tfedit-test,private",
},
}

for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
got := importIDFuncAWSS3BucketACL(tc.r)
var r schema.Resource
if err := json.Unmarshal([]byte(tc.resource), &r); err != nil {
t.Fatalf("failed to unmarshal json: %s", err)
}

got := importIDFuncAWSS3BucketACL(r)

if got != tc.want {
t.Errorf("got = %s, but want = %s", got, tc.want)
Expand Down

0 comments on commit 252b08d

Please sign in to comment.