-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address review comments for
aws_quicksight_user
by
- Using go-sdk constants - Running, fixing and cleaning tests Here's my current test output ``` bash AWS_DEFAULT_REGION=us-east-1 AWS_PROFILE=default TF_ACC=1 go test ./aws -v -timeout 120m -parallel 20 -run='TestAccAWSQuickSightUser_' ``` > go: finding github.com/terraform-providers/terraform-provider-tls > v2.1.1+incompatible > go: finding github.com/terraform-providers/terraform-provider-tls > v2.1.1+incompatible > === RUN TestAccAWSQuickSightUser_basic > === PAUSE TestAccAWSQuickSightUser_basic > === RUN TestAccAWSQuickSightUser_withInvalidFormattedEmailStillWorks > === PAUSE TestAccAWSQuickSightUser_withInvalidFormattedEmailStillWorks > === RUN TestAccAWSQuickSightUser_disappears > === PAUSE TestAccAWSQuickSightUser_disappears > === CONT TestAccAWSQuickSightUser_basic > === CONT TestAccAWSQuickSightUser_disappears > === CONT TestAccAWSQuickSightUser_withInvalidFormattedEmailStillWorks > --- PASS: TestAccAWSQuickSightUser_disappears (14.19s) > --- PASS: TestAccAWSQuickSightUser_basic (25.44s) > --- PASS: TestAccAWSQuickSightUser_withInvalidFormattedEmailStillWorks > (26.08s) > PASS > ok github.com/terraform-providers/terraform-provider-aws/aws > 26.109s Note that the tests exposed that the `describe-user` QuickSight API does not return the schema that is documented. For example, when I run it via the CLI I get ``` json { "RequestId": "some-guid-looking-thing", "Status": 200, "User": { "Arn": "arn:aws:quicksight:us-west-2:01234567890:user/default/some_user", "PrincipalId": "federated/iam/some_user", "Email": "[email protected]", "Active": true, "Role": "ADMIN", "UserName": "some_user" } } ``` Notice that `IdentityType` is missing though documented! This means that I had to remove it from attributes and remove the importer :( since we can't reconcile that value. If there's a way around this please let me know. Also note that I couldn't use `acctest.RandomWithPrefix` because the resultant username was not valid in QuickSight.
- Loading branch information
Showing
4 changed files
with
29 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,10 @@ import ( | |
|
||
func TestAccAWSQuickSightUser_basic(t *testing.T) { | ||
var user quicksight.User | ||
resourceName := "aws_quicksight_user.default" | ||
rName1 := acctest.RandomWithPrefix("tf-acc-test") | ||
rName2 := acctest.RandomWithPrefix("tf-acc-test") | ||
rName1 := "tfacctest" + acctest.RandString(10) | ||
resourceName1 := "aws_quicksight_user." + rName1 | ||
rName2 := "tfacctest" + acctest.RandString(10) | ||
resourceName2 := "aws_quicksight_user." + rName2 | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
|
@@ -28,32 +29,27 @@ func TestAccAWSQuickSightUser_basic(t *testing.T) { | |
{ | ||
Config: testAccAWSQuickSightUserConfig(rName1), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckQuickSightUserExists(resourceName, &user), | ||
resource.TestCheckResourceAttr(resourceName, "user_name", rName1), | ||
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "quicksight", fmt.Sprintf("user/default/%s", rName1)), | ||
testAccCheckQuickSightUserExists(resourceName1, &user), | ||
resource.TestCheckResourceAttr(resourceName1, "user_name", rName1), | ||
testAccCheckResourceAttrRegionalARN(resourceName1, "arn", "quicksight", fmt.Sprintf("user/default/%s", rName1)), | ||
), | ||
}, | ||
{ | ||
Config: testAccAWSQuickSightUserConfig(rName2), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckQuickSightUserExists(resourceName, &user), | ||
resource.TestCheckResourceAttr(resourceName, "user_name", rName2), | ||
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "quicksight", fmt.Sprintf("user/default/%s", rName2)), | ||
testAccCheckQuickSightUserExists(resourceName2, &user), | ||
resource.TestCheckResourceAttr(resourceName2, "user_name", rName2), | ||
testAccCheckResourceAttrRegionalARN(resourceName2, "arn", "quicksight", fmt.Sprintf("user/default/%s", rName2)), | ||
), | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAWSQuickSightUser_withRealEmail(t *testing.T) { | ||
func TestAccAWSQuickSightUser_withInvalidFormattedEmailStillWorks(t *testing.T) { | ||
var user quicksight.User | ||
resourceName := "aws_quicksight_user.default" | ||
rName := acctest.RandomWithPrefix("tf-acc-test") | ||
rName := "tfacctest" + acctest.RandString(10) | ||
resourceName := "aws_quicksight_user." + rName | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
|
@@ -74,19 +70,14 @@ func TestAccAWSQuickSightUser_withRealEmail(t *testing.T) { | |
resource.TestCheckResourceAttr(resourceName, "email", "nottarealemailbutworks2"), | ||
), | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAWSQuickSightUser_disappears(t *testing.T) { | ||
var user quicksight.User | ||
resourceName := "aws_quicksight_user.default" | ||
rName := acctest.RandomWithPrefix("tf-acc-test") | ||
rName := "tfacctest" + acctest.RandString(10) | ||
resourceName := "aws_quicksight_user." + rName | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
|
@@ -197,27 +188,20 @@ func testAccCheckQuickSightUserDisappears(v *quicksight.User) resource.TestCheck | |
} | ||
} | ||
|
||
func testAccAWSQuickSightUserConfig(rName string) string { | ||
return fmt.Sprintf(` | ||
resource "aws_quicksight_user" "default" { | ||
user_name = %[1]q | ||
email = "[email protected]" | ||
identity_type = "IAM" | ||
user_role = "READER" | ||
} | ||
`, rName) | ||
} | ||
|
||
func testAccAWSQuickSightUserConfigWithEmail(rName, email string) string { | ||
return fmt.Sprintf(` | ||
data "aws_caller_identity" "current" {} | ||
resource "aws_quicksight_user" "default" { | ||
resource "aws_quicksight_user" %[1]q { | ||
aws_account_id = "${data.aws_caller_identity.current.account_id}" | ||
user_name = %[1]q | ||
email = %[2]q | ||
identity_type = "IAM" | ||
identity_type = "QUICKSIGHT" | ||
user_role = "READER" | ||
} | ||
`, rName, email) | ||
} | ||
|
||
func testAccAWSQuickSightUserConfig(rName string) string { | ||
return testAccAWSQuickSightUserConfigWithEmail(rName, "[email protected]") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters