forked from mondoohq/terraform-provider-mondoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matthias Theuermann <[email protected]>
- Loading branch information
1 parent
d878ea7
commit 0c70b8a
Showing
1 changed file
with
13 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,16 @@ func TestAccZendeskResource(t *testing.T) { | |
Steps: []resource.TestStep{ | ||
// Create and Read testing | ||
{ | ||
Config: testAccZendeskResourceConfig(accSpace.ID(), "one", "your-subdomain", "[email protected]", []customField{ | ||
{ID: "123456", Value: "custom_value_1"}, | ||
{ID: "123457", Value: "custom_value_2"}, | ||
}), | ||
Config: testAccZendeskResourceConfig(accSpace.ID(), "one", "your-subdomain", "[email protected]", `[ | ||
{id: "123456", value: "custom_value_1"}, | ||
{id: "123457", value: "custom_value_2"}, | ||
]`), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "name", "one"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "space_id", accSpace.ID()), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "subdomain", "your-subdomain"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "email", "[email protected]"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "custom_fields.#", "2"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "custom_fields.0.value", "custom_value_1"), | ||
), | ||
}, | ||
{ | ||
|
@@ -36,20 +36,20 @@ func TestAccZendeskResource(t *testing.T) { | |
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "space_id", accSpace.ID()), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "auto_create", "true"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "auto_close", "true"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "credentials.0.token", "abctoken12345"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "credentials.token", "abctoken12345"), | ||
), | ||
}, | ||
// Update and Read testing | ||
{ | ||
Config: testAccZendeskResourceConfig(accSpace.ID(), "three", "updated-subdomain", "[email protected]", []customField{ | ||
{ID: "123456", Value: "new_custom_value_1"}, | ||
}), | ||
Config: testAccZendeskResourceConfig(accSpace.ID(), "three", "updated-subdomain", "[email protected]", `[ | ||
{id: "123456", value: "new_custom_value_1"}, | ||
]`), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "name", "three"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "space_id", accSpace.ID()), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "subdomain", "updated-subdomain"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "email", "[email protected]"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "custom_fields.#", "1"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "custom_fields.0.value", "new_custom_value_1"), | ||
), | ||
}, | ||
{ | ||
|
@@ -59,25 +59,23 @@ func TestAccZendeskResource(t *testing.T) { | |
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "space_id", accSpace.ID()), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "auto_create", "false"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "auto_close", "false"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "credentials.0.token", "0987xyzabc7654"), | ||
resource.TestCheckResourceAttr("mondoo_integration_zendesk.test", "credentials.token", "0987xyzabc7654"), | ||
), | ||
}, | ||
// Delete testing automatically occurs in TestCase | ||
}, | ||
}) | ||
} | ||
|
||
func testAccZendeskResourceConfig(spaceID, name, subdomain, email string, customFields []customField) string { | ||
func testAccZendeskResourceConfig(spaceID, name, subdomain, email, customFields string) string { | ||
return fmt.Sprintf(` | ||
resource "mondoo_integration_zendesk" "test" { | ||
space_id = %[1]q | ||
name = %[2]q | ||
subdomain = %[3]q | ||
email = %[4]q | ||
custom_fields = [ | ||
%[5]s | ||
] | ||
custom_fields = %[5]s | ||
auto_create = true | ||
auto_close = true | ||
|
@@ -89,11 +87,6 @@ resource "mondoo_integration_zendesk" "test" { | |
`, spaceID, name, subdomain, email, customFields) | ||
} | ||
|
||
type customField struct { | ||
ID string | ||
Value string | ||
} | ||
|
||
func testAccZendeskResourceWithSpaceInProviderConfig(spaceID, intName, token string, autoCreate, autoClose bool) string { | ||
return fmt.Sprintf(` | ||
provider "mondoo" { | ||
|