Skip to content

Commit 2ae4d9e

Browse files
committed
Fix missing test checks in the resource user
1 parent e0f62ef commit 2ae4d9e

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

gitlab/resource_gitlab_user_test.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
2626
Check: resource.ComposeTestCheckFunc(
2727
testAccCheckGitlabUserExists("gitlab_user.foo", &user),
2828
testAccCheckGitlabUserAttributes(&user, &testAccGitlabUserExpectedAttributes{
29-
Email: "listest%[email protected]",
29+
Email: fmt.Sprintf("listest%[email protected]", rInt),
3030
Password: fmt.Sprintf("test%dtt", rInt),
3131
Username: fmt.Sprintf("listest%d", rInt),
3232
Name: fmt.Sprintf("foo %d", rInt),
@@ -38,13 +38,13 @@ func TestAccGitlabUser_basic(t *testing.T) {
3838
}),
3939
),
4040
},
41-
// Update the user to change the name
41+
// Update the user to change the name, email, projects_limit and more
4242
{
4343
Config: testAccGitlabUserUpdateConfig(rInt),
4444
Check: resource.ComposeTestCheckFunc(
4545
testAccCheckGitlabUserExists("gitlab_user.foo", &user),
4646
testAccCheckGitlabUserAttributes(&user, &testAccGitlabUserExpectedAttributes{
47-
Email: "listest%[email protected]",
47+
Email: fmt.Sprintf("listest%[email protected]", rInt),
4848
Password: fmt.Sprintf("test%dtt", rInt),
4949
Username: fmt.Sprintf("listest%d", rInt),
5050
Name: fmt.Sprintf("bar %d", rInt),
@@ -62,7 +62,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
6262
Check: resource.ComposeTestCheckFunc(
6363
testAccCheckGitlabUserExists("gitlab_user.foo", &user),
6464
testAccCheckGitlabUserAttributes(&user, &testAccGitlabUserExpectedAttributes{
65-
Email: "listest%[email protected]",
65+
Email: fmt.Sprintf("listest%[email protected]", rInt),
6666
Password: fmt.Sprintf("test%dtt", rInt),
6767
Username: fmt.Sprintf("listest%d", rInt),
6868
Name: fmt.Sprintf("foo %d", rInt),
@@ -151,6 +151,26 @@ func testAccCheckGitlabUserAttributes(user *gitlab.User, want *testAccGitlabUser
151151
return fmt.Errorf("got username %q; want %q", user.Username, want.Username)
152152
}
153153

154+
if user.Email != want.Email {
155+
return fmt.Errorf("got email %q; want %q", user.Email, want.Email)
156+
}
157+
158+
if user.CanCreateGroup != want.CanCreateGroup {
159+
return fmt.Errorf("got can_create_group %t; want %t", user.CanCreateGroup, want.CanCreateGroup)
160+
}
161+
162+
if user.External != want.External {
163+
return fmt.Errorf("got is_external %t; want %t", user.External, want.External)
164+
}
165+
166+
if user.IsAdmin != want.Admin {
167+
return fmt.Errorf("got is_admin %t; want %t", user.IsAdmin, want.Admin)
168+
}
169+
170+
if user.ProjectsLimit != want.ProjectsLimit {
171+
return fmt.Errorf("got projects_limit %d; want %d", user.ProjectsLimit, want.ProjectsLimit)
172+
}
173+
154174
return nil
155175
}
156176
}

0 commit comments

Comments
 (0)