Skip to content

Commit 3e56298

Browse files
add tests
1 parent 341f8c0 commit 3e56298

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

codefresh/resource_abac_rules_test.go

+52-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import (
66
"testing"
77

88
"github.com/codefresh-io/terraform-provider-codefresh/codefresh/cfclient"
9-
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
10-
119
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
10+
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1211
funk "github.com/thoas/go-funk"
1312
)
1413

@@ -41,6 +40,57 @@ func TestAccCodefreshAbacRulesConfig(t *testing.T) {
4140
resource.TestCheckResourceAttr(resourceName, "tags.1", "production"),
4241
),
4342
},
43+
{
44+
Config: testAccCodefreshAbacRulesConfig(
45+
"promotionFlows",
46+
"",
47+
"",
48+
"",
49+
[]string{"TRIGGER_PROMOTION"},
50+
[]string{"staging"},
51+
),
52+
Check: resource.ComposeTestCheckFunc(
53+
testAccCheckCodefreshAbacRulesExists(resourceName),
54+
resource.TestCheckResourceAttr(resourceName, "entity_type", "promotionFlows"),
55+
resource.TestCheckResourceAttr(resourceName, "actions.0", "TRIGGER_PROMOTION"),
56+
resource.TestCheckResourceAttr(resourceName, "tags.0", "staging"),
57+
),
58+
},
59+
{
60+
Config: testAccCodefreshAbacRulesConfig(
61+
"products",
62+
"",
63+
"",
64+
"",
65+
[]string{"TRIGGER_PROMOTION", "RETRY_RELEASE"},
66+
[]string{"dev", "qa"},
67+
),
68+
Check: resource.ComposeTestCheckFunc(
69+
testAccCheckCodefreshAbacRulesExists(resourceName),
70+
resource.TestCheckResourceAttr(resourceName, "entity_type", "products"),
71+
resource.TestCheckResourceAttr(resourceName, "actions.#", "2"),
72+
resource.TestCheckTypeSetElemAttr(resourceName, "actions.*", "TRIGGER_PROMOTION"),
73+
resource.TestCheckTypeSetElemAttr(resourceName, "actions.*", "RETRY_RELEASE"),
74+
resource.TestCheckResourceAttr(resourceName, "tags.0", "dev"),
75+
resource.TestCheckResourceAttr(resourceName, "tags.1", "qa"),
76+
),
77+
},
78+
{
79+
Config: testAccCodefreshAbacRulesConfig(
80+
"environments",
81+
"",
82+
"",
83+
"",
84+
[]string{"PROMOTE_TO"},
85+
[]string{"production"},
86+
),
87+
Check: resource.ComposeTestCheckFunc(
88+
testAccCheckCodefreshAbacRulesExists(resourceName),
89+
resource.TestCheckResourceAttr(resourceName, "entity_type", "environments"),
90+
resource.TestCheckResourceAttr(resourceName, "actions.0", "PROMOTE_TO"),
91+
resource.TestCheckResourceAttr(resourceName, "tags.0", "production"),
92+
),
93+
},
4494
{
4595
ResourceName: resourceName,
4696
ImportState: true,

0 commit comments

Comments
 (0)