@@ -2,6 +2,7 @@ package gitlab
22
33import (
44 "fmt"
5+ "regexp"
56 "strconv"
67 "testing"
78
@@ -96,7 +97,12 @@ func TestAccGitlabUser_password_reset(t *testing.T) {
9697 Providers : testAccProviders ,
9798 CheckDestroy : testAccCheckGitlabGroupDestroy ,
9899 Steps : []resource.TestStep {
99- // Create a user
100+ // Test that either password or reset_password is needed
101+ {
102+ Config : testAccGitlabUserConfigWrong (rInt ),
103+ ExpectError : regexp .MustCompile (`\sAt least one of either password or reset_password must be defined` ),
104+ },
105+ // Create a user without a password
100106 {
101107 Config : testAccGitlabUserConfigPasswordReset (rInt ),
102108 Check : testAccCheckGitlabUserExists ("gitlab_user.foo" , & user ),
@@ -214,13 +220,18 @@ func testAccGitlabUserConfigPasswordReset(rInt int) string {
214220resource "gitlab_user" "foo" {
215221 name = "foo %d"
216222 username = "listest%d"
217- password = "test%dtt"
218223 email = "listest%d@ssss.com"
219- is_admin = false
220- projects_limit = 0
221- can_create_group = false
222- is_external = false
223224 reset_password = true
224225}
225- ` , rInt , rInt , rInt , rInt )
226+ ` , rInt , rInt , rInt )
227+ }
228+
229+ func testAccGitlabUserConfigWrong (rInt int ) string {
230+ return fmt .Sprintf (`
231+ resource "gitlab_user" "foo" {
232+ name = "foo %d"
233+ username = "listest%d"
234+ email = "listest%d@ssss.com"
235+ }
236+ ` , rInt , rInt , rInt )
226237}
0 commit comments