Skip to content

Commit

Permalink
Add data lake settings to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcmessias committed Jun 3, 2021
1 parent 1281ce6 commit ba62404
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions aws/resource_aws_lakeformation_policy_tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,15 @@ func testAccCheckAWSLakeFormationPolicyTagsDestroy(s *terraform.State) error {
CatalogId: aws.String(catalogID),
TagKey: aws.String(tagKey),
}

if _, err := conn.GetLFTag(input); err != nil {
if isAWSErr(err, lakeformation.ErrCodeEntityNotFoundException, "") {
continue
}
// If the lake formation admin has been revoked, there will be access denied instead of entity not found
if isAWSErr(err, lakeformation.ErrCodeAccessDeniedException, "") {
continue
}
return err
}
return fmt.Errorf("Lake Formation Policy Tag (%s) still exists", rs.Primary.ID)
Expand Down Expand Up @@ -166,9 +171,18 @@ func testAccCheckAWSLakeFormationPolicyTagExists(name string) resource.TestCheck

func testAccAWSLakeFormationPolicyTagConfig_basic(rKey string) string {
return fmt.Sprintf(`
data "aws_caller_identity" "current" {}
resource "aws_lakeformation_data_lake_settings" "test" {
admins = [data.aws_caller_identity.current.arn]
}
resource "aws_lakeformation_policy_tag" "test" {
key = %[1]q
key = %[1]q
values = ["value"]
# for consistency, ensure that admins are setup before testing
depends_on = [aws_lakeformation_data_lake_settings.test]
}
`, rKey)
}
Expand All @@ -180,9 +194,18 @@ func testAccAWSLakeFormationPolicyTagConfig_values(rKey string, values []string)
}

return fmt.Sprintf(`
data "aws_caller_identity" "current" {}
resource "aws_lakeformation_data_lake_settings" "test" {
admins = [data.aws_caller_identity.current.arn]
}
resource "aws_lakeformation_policy_tag" "test" {
key = %[1]q
key = %[1]q
values = [%s]
# for consistency, ensure that admins are setup before testing
depends_on = [aws_lakeformation_data_lake_settings.test]
}
`, rKey, strings.Join(quotedValues, ","))
}

0 comments on commit ba62404

Please sign in to comment.