Skip to content

Commit

Permalink
Add 'TestAccAppFlowFlow_taskUpdate'.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Nov 17, 2023
1 parent cf28d0b commit e766888
Showing 1 changed file with 169 additions and 5 deletions.
174 changes: 169 additions & 5 deletions internal/service/appflow/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestAccAppFlowFlow_update(t *testing.T) {
})
}

func TestAccAppFlowFlow_TaskProperties(t *testing.T) {
func TestAccAppFlowFlow_taskProperties(t *testing.T) {
ctx := acctest.Context(t)
var flowOutput types.FlowDefinition
rSourceName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
Expand All @@ -184,6 +184,88 @@ func TestAccAppFlowFlow_TaskProperties(t *testing.T) {
})
}

func TestAccAppFlowFlow_taskUpdate(t *testing.T) {
ctx := acctest.Context(t)
var flowOutput types.FlowDefinition
rSourceName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
rDestinationName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
rFlowName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appflow_flow.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.AppFlowEndpointID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckFlowDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccFlowConfig_multipleTasks(rSourceName, rDestinationName, rFlowName, "aThirdTestField"),
Check: resource.ComposeTestCheckFunc(
testAccCheckFlowExists(ctx, resourceName, &flowOutput),
resource.TestCheckResourceAttr(resourceName, "task.#", "3"),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "task.*", map[string]string{
"destination_field": "",
"source_fields.#": "2",
"source_fields.0": "testField",
"source_fields.1": "anotherTestField",
"task_type": "Filter",
}),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "task.*", map[string]string{
"destination_field": "testField",
"source_fields.#": "1",
"source_fields.0": "testField",
"task_properties.%": "2",
"task_properties.DESTINATION_DATA_TYPE": "string",
"task_properties.SOURCE_DATA_TYPE": "string",
"task_type": "Map",
}),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "task.*", map[string]string{
"destination_field": "aThirdTestField",
"source_fields.#": "1",
"source_fields.0": "aThirdTestField",
"task_properties.%": "2",
"task_properties.DESTINATION_DATA_TYPE": "id",
"task_properties.SOURCE_DATA_TYPE": "id",
"task_type": "Map",
}),
),
},
{
Config: testAccFlowConfig_multipleTasks(rSourceName, rDestinationName, rFlowName, "anotherField"),
Check: resource.ComposeTestCheckFunc(
testAccCheckFlowExists(ctx, resourceName, &flowOutput),
resource.TestCheckResourceAttr(resourceName, "task.#", "3"),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "task.*", map[string]string{
"destination_field": "",
"source_fields.#": "2",
"source_fields.0": "testField",
"source_fields.1": "anotherTestField",
"task_type": "Filter",
}),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "task.*", map[string]string{
"destination_field": "testField",
"source_fields.#": "1",
"source_fields.0": "testField",
"task_properties.%": "2",
"task_properties.DESTINATION_DATA_TYPE": "string",
"task_properties.SOURCE_DATA_TYPE": "string",
"task_type": "Map",
}),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "task.*", map[string]string{
"destination_field": "anotherField",
"source_fields.#": "1",
"source_fields.0": "anotherField",
"task_properties.%": "2",
"task_properties.DESTINATION_DATA_TYPE": "id",
"task_properties.SOURCE_DATA_TYPE": "id",
"task_type": "Map",
}),
),
},
},
})
}

func TestAccAppFlowFlow_tags(t *testing.T) {
ctx := acctest.Context(t)
var flowOutput types.FlowDefinition
Expand Down Expand Up @@ -464,7 +546,7 @@ resource "aws_appflow_flow" "test" {
)
}

func testAccFlowConfig_update(rSourceName string, rDestinationName string, rFlowName string, description string) string {
func testAccFlowConfig_update(rSourceName, rDestinationName, rFlowName, description string) string {
return acctest.ConfigCompose(
testAccFlowConfig_base(rSourceName, rDestinationName),
fmt.Sprintf(`
Expand Down Expand Up @@ -522,7 +604,7 @@ resource "aws_appflow_flow" "test" {
)
}

func testAccFlowConfig_taskProperties(rSourceName string, rDestinationName string, rFlowName string) string {
func testAccFlowConfig_taskProperties(rSourceName, rDestinationName, rFlowName string) string {
return acctest.ConfigCompose(
testAccFlowConfig_base(rSourceName, rDestinationName),
fmt.Sprintf(`
Expand Down Expand Up @@ -577,7 +659,89 @@ resource "aws_appflow_flow" "test" {
)
}

func testAccFlowConfig_tags1(rSourceName string, rDestinationName string, rFlowName string, tagKey1 string, tagValue1 string) string {
func testAccFlowConfig_multipleTasks(rSourceName, rDestinationName, rFlowName, fieldName string) string {
return acctest.ConfigCompose(
testAccFlowConfig_base(rSourceName, rDestinationName),
fmt.Sprintf(`
resource "aws_appflow_flow" "test" {
name = %[1]q
source_flow_config {
connector_type = "S3"
source_connector_properties {
s3 {
bucket_name = aws_s3_bucket_policy.test_source.bucket
bucket_prefix = "flow"
}
}
}
destination_flow_config {
connector_type = "S3"
destination_connector_properties {
s3 {
bucket_name = aws_s3_bucket_policy.test_destination.bucket
s3_output_format_config {
prefix_config {
prefix_type = "PATH"
}
}
}
}
}
task {
source_fields = [
"testField",
"anotherTestField"
]
connector_operator {
s3 = "PROJECTION"
}
task_type = "Filter"
destination_field = ""
}
task {
source_fields = ["testField"]
destination_field = "testField"
task_type = "Map"
connector_operator {
s3 = "NO_OP"
}
task_properties = {
"DESTINATION_DATA_TYPE" = "string"
"SOURCE_DATA_TYPE" = "string"
}
}
task {
source_fields = [%[2]q]
destination_field = %[2]q
task_type = "Map"
connector_operator {
s3 = "NO_OP"
}
task_properties = {
"DESTINATION_DATA_TYPE" = "id"
"SOURCE_DATA_TYPE" = "id"
}
}
trigger_config {
trigger_type = "OnDemand"
}
}
`, rFlowName, fieldName),
)
}

func testAccFlowConfig_tags1(rSourceName, rDestinationName, rFlowName string, tagKey1 string, tagValue1 string) string {
return acctest.ConfigCompose(
testAccFlowConfig_base(rSourceName, rDestinationName),
fmt.Sprintf(`
Expand Down Expand Up @@ -631,7 +795,7 @@ resource "aws_appflow_flow" "test" {
)
}

func testAccFlowConfig_tags2(rSourceName string, rDestinationName string, rFlowName string, tagKey1 string, tagValue1 string, tagKey2 string, tagValue2 string) string {
func testAccFlowConfig_tags2(rSourceName, rDestinationName, rFlowName string, tagKey1 string, tagValue1 string, tagKey2 string, tagValue2 string) string {
return acctest.ConfigCompose(
testAccFlowConfig_base(rSourceName, rDestinationName),
fmt.Sprintf(`
Expand Down

0 comments on commit e766888

Please sign in to comment.