-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
117d2e7
commit ce8130e
Showing
2 changed files
with
85 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package acceptance | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/google/uuid" | ||
"github.com/hashicorp/terraform-plugin-testing/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
) | ||
|
||
func TestAccResourceWizUser_basic(t *testing.T) { | ||
rName := acctest.RandomWithPrefix(ResourcePrefix) | ||
smtpDomain := os.Getenv("WIZ_SMTP_DOMAIN") | ||
resource.UnitTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheckUser(t) }, | ||
ProviderFactories: providerFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testResourceWizUserBasic(rName, smtpDomain), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr( | ||
// check that name is correctly set | ||
"wiz_user.foo", | ||
"name", | ||
rName, | ||
), | ||
resource.TestCheckResourceAttr( | ||
// check that email is correctly set | ||
"wiz_user.foo", | ||
"email", | ||
fmt.Sprintf("%s@%s", rName, smtpDomain), | ||
), | ||
resource.TestCheckResourceAttr( | ||
// check that role is set to specified value | ||
"wiz_user.foo", | ||
"role", | ||
"PROJECT_MEMBER", | ||
), | ||
resource.TestCheckResourceAttrSet( | ||
// check for a set assigned project id | ||
"wiz_user.foo", | ||
"assigned_project_ids.0", | ||
), | ||
resource.TestCheckResourceAttrSet( | ||
// check that send_email_invite is set (can be null) | ||
"wiz_user.foo", | ||
"send_email_invite", | ||
), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testResourceWizUserBasic(rName string, smtpDomain string) string { | ||
project := uuid.New().String() | ||
return fmt.Sprintf(` | ||
resource "wiz_user" "foo" { | ||
name = "%[1]s" | ||
email = "%[1]s@%s" | ||
role = "PROJECT_MEMBER" | ||
assigned_project_ids = [ "%s" ] | ||
} | ||
`, rName, smtpDomain, project) | ||
} |