Skip to content

Commit

Permalink
🧹 fix acceptance tests
Browse files Browse the repository at this point in the history
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
  • Loading branch information
afiune committed Dec 10, 2024
1 parent 74bd074 commit 017a715
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
18 changes: 9 additions & 9 deletions internal/provider/integration_email_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func TestAccEmailIntegrationResource(t *testing.T) {
Steps: []resource.TestStep{
// Create and Read testing
{
Config: testAccEmailIntegrationResourceConfig(accSpace.ID(), "one", []map[string]interface{}{
Config: testAccEmailIntegrationResourceConfig(accSpace.ID(), "one", `[
{"name": "John Doe", "email": "john@example.com", "is_default": true, "reference_url": "https://example.com"},
{"name": "Alice Doe", "email": "alice@example.com", "is_default": false, "reference_url": "https://example.com"},
}),
{"name": "Alice Doe", "email": "alice@example.com", "is_default": false, "reference_url": "https://example.com"}
]`),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("mondoo_integration_email.test", "name", "one"),
resource.TestCheckResourceAttr("mondoo_integration_email.test", "space_id", accSpace.ID()),
Expand All @@ -38,10 +38,10 @@ func TestAccEmailIntegrationResource(t *testing.T) {
},
// Update and Read testing
{
Config: testAccEmailIntegrationResourceConfig(accSpace.ID(), "three", []map[string]interface{}{
Config: testAccEmailIntegrationResourceConfig(accSpace.ID(), "three", `[
{"name": "John Doe", "email": "john.doe@example.com", "is_default": true, "reference_url": "https://newurl.com"},
{"name": "Alice Doe", "email": "alice.doe@example.com", "is_default": false, "reference_url": "https://newurl.com"},
}),
{"name": "Alice Doe", "email": "alice.doe@example.com", "is_default": false, "reference_url": "https://newurl.com"}
]`),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("mondoo_integration_email.test", "name", "three"),
resource.TestCheckResourceAttr("mondoo_integration_email.test", "space_id", accSpace.ID()),
Expand All @@ -62,12 +62,12 @@ func TestAccEmailIntegrationResource(t *testing.T) {
})
}

func testAccEmailIntegrationResourceConfig(spaceID, intName string, recipients []map[string]interface{}) string {
func testAccEmailIntegrationResourceConfig(spaceID, intName, recipients string) string {
return fmt.Sprintf(`
resource "mondoo_integration_email" "test" {
space_id = %[1]q
name = %[2]q
recipients = %[3]q
recipients = %[3]s
auto_create = true
auto_close = true
}
Expand All @@ -79,7 +79,7 @@ func testAccEmailIntegrationResourceWithSpaceInProviderConfig(spaceID, intName s
provider "mondoo" {
space = %[1]q
}
resource "mondoo_integration_email" "email_integration" {
resource "mondoo_integration_email" "test" {
name = %[2]q
recipients = [
{
Expand Down
38 changes: 19 additions & 19 deletions internal/provider/integration_gitlab_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func TestAccGitLabResource(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "name", "one"),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "space_id", accSpace.ID()),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "discovery.0.groups", "true"),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "discovery.groups", "true"),
),
},
{
Config: testAccGitLabResourceWithSpaceInProviderConfig(accSpace.ID(), "two", "abctoken12345"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "name", "two"),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "space_id", accSpace.ID()),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "credentials.0.token", "abctoken12345"),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "credentials.token", "abctoken12345"),
),
},
// ImportState testing
Expand All @@ -46,15 +46,15 @@ func TestAccGitLabResource(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "name", "one"),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "space_id", accSpace.ID()),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "discovery.0.groups", "true"),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "discovery.groups", "true"),
),
},
{
Config: testAccGitLabResourceWithSpaceInProviderConfig(accSpace.ID(), "two", "abctoken12345"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "name", "two"),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "space_id", accSpace.ID()),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "credentials.0.token", "abctoken12345"),
resource.TestCheckResourceAttr("mondoo_integration_gitlab.test", "credentials.token", "abctoken12345"),
),
},
// Delete testing automatically occurs in TestCase
Expand All @@ -66,17 +66,17 @@ func testAccGitLabResourceConfig(spaceID, intName string, discoveryGroup bool) s
return fmt.Sprintf(`
resource "mondoo_integration_gitlab" "test" {
space_id = %[1]q
name = %[2]q
name = %[2]q
base_url = "https://my-self-hosted-gitlab.com"
group = "my-group"
group = "my-group"
discovery = {
groups = %[3]t
projects = true
terraform = true
k8s_manifests = true
groups = %[3]t
projects = true
terraform = true
k8s_manifests = true
}
credentials = {
token = "abcd1234567890"
token = "abcd1234567890"
}
}
`, spaceID, intName, discoveryGroup)
Expand All @@ -85,20 +85,20 @@ resource "mondoo_integration_gitlab" "test" {
func testAccGitLabResourceWithSpaceInProviderConfig(spaceID, intName, token string) string {
return fmt.Sprintf(`
provider "mondoo" {
space = %[1]q
space = %[1]q
}
resource "mondoo_integration_gitlab" "test" {
name = %[2]q
name = %[2]q
base_url = "https://my-self-hosted-gitlab.com"
group = "my-group"
group = "my-group"
discovery = {
groups = true
projects = true
terraform = true
k8s_manifests = true
groups = true
projects = true
terraform = true
k8s_manifests = true
}
credentials = {
token = %[3]q
token = %[3]q
}
}
`, spaceID, intName, token)
Expand Down

0 comments on commit 017a715

Please sign in to comment.