Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielm-codefresh committed Sep 10, 2024
1 parent 341f8c0 commit 837e139
Showing 1 changed file with 53 additions and 2 deletions.
55 changes: 53 additions & 2 deletions codefresh/resource_abac_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"testing"

"github.com/codefresh-io/terraform-provider-codefresh/codefresh/cfclient"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
funk "github.com/thoas/go-funk"
)

Expand Down Expand Up @@ -41,6 +40,58 @@ func TestAccCodefreshAbacRulesConfig(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "tags.1", "production"),
),
},
{
Config: testAccCodefreshAbacRulesConfig(
"promotionFlows",
"",
"",
"",
[]string{"TRIGGER_PROMOTION"},
[]string{"staging"},
),
Check: resource.ComposeTestCheckFunc(
testAccCheckCodefreshAbacRulesExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "entity_type", "promotionFlows"),
resource.TestCheckResourceAttr(resourceName, "actions.0", "TRIGGER_PROMOTION"),
resource.TestCheckResourceAttr(resourceName, "tags.0", "staging"),
),
},
{
Config: testAccCodefreshAbacRulesConfig(
"products",
"",
"",
"",
[]string{"TRIGGER_PROMOTION", "RETRY_RELEASE"},
[]string{"dev", "qa"},
),
Check: resource.ComposeTestCheckFunc(
testAccCheckCodefreshAbacRulesExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "entity_type", "products"),
resource.TestCheckResourceAttr(resourceName, "actions.#", "2"),
resource.TestCheckTypeSetElemAttr(resourceName, "actions.*", "TRIGGER_PROMOTION"),
resource.TestCheckTypeSetElemAttr(resourceName, "actions.*", "RETRY_RELEASE"),
resource.TestCheckResourceAttr(resourceName, "tags.#", "2"),
resource.TestCheckTypeSetElemAttr(resourceName, "tags.*", "dev"),
resource.TestCheckTypeSetElemAttr(resourceName, "tags.*", "qa"),
),
},
{
Config: testAccCodefreshAbacRulesConfig(
"environments",
"",
"",
"",
[]string{"PROMOTE_TO"},
[]string{"production"},
),
Check: resource.ComposeTestCheckFunc(
testAccCheckCodefreshAbacRulesExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "entity_type", "environments"),
resource.TestCheckResourceAttr(resourceName, "actions.0", "PROMOTE_TO"),
resource.TestCheckResourceAttr(resourceName, "tags.0", "production"),
),
},
{
ResourceName: resourceName,
ImportState: true,
Expand Down

0 comments on commit 837e139

Please sign in to comment.