-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
resource_arm_logic_app_action_custom_test.go
112 lines (97 loc) · 3.15 KB
/
resource_arm_logic_app_action_custom_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package tests
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance"
)
func TestAccAzureRMLogicAppActionCustom_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_logic_app_action_custom", "test")
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMLogicAppWorkflowDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLogicAppActionCustom_basic(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLogicAppActionExists(data.ResourceName),
),
},
data.ImportStep(),
},
})
}
func TestAccAzureRMLogicAppActionCustom_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_logic_app_action_custom", "test")
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMLogicAppWorkflowDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLogicAppActionCustom_basic(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLogicAppActionExists(data.ResourceName),
),
},
{
Config: testAccAzureRMLogicAppActionCustom_requiresImport(data),
ExpectError: acceptance.RequiresImportError("azurerm_logic_app_action_custom"),
},
},
})
}
func testAccAzureRMLogicAppActionCustom_basic(data acceptance.TestData) string {
template := testAccAzureRMLogicAppActionCustom_template(data)
return fmt.Sprintf(`
%s
resource "azurerm_logic_app_action_custom" "test" {
name = "action%d"
logic_app_id = azurerm_logic_app_workflow.test.id
body = <<BODY
{
"description": "A variable to configure the auto expiration age in days. Configured in negative number. Default is -30 (30 days old).",
"inputs": {
"variables": [
{
"name": "ExpirationAgeInDays",
"type": "Integer",
"value": -30
}
]
},
"runAfter": {},
"type": "InitializeVariable"
}
BODY
}
`, template, data.RandomInteger)
}
func testAccAzureRMLogicAppActionCustom_requiresImport(data acceptance.TestData) string {
template := testAccAzureRMLogicAppActionCustom_basic(data)
return fmt.Sprintf(`
%s
resource "azurerm_logic_app_action_custom" "import" {
name = azurerm_logic_app_action_custom.test.name
logic_app_id = azurerm_logic_app_action_custom.test.logic_app_id
body = azurerm_logic_app_action_custom.test.body
}
`, template)
}
func testAccAzureRMLogicAppActionCustom_template(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_logic_app_workflow" "test" {
name = "acctestlaw-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}