Skip to content

Commit

Permalink
gitlab_user tests refactor: Remove Password and SkipConfirmation fiel…
Browse files Browse the repository at this point in the history
…ds from testAccGitlabUserExpectedAttributes struct

These fields were not being checked in testAccCheckGitlabUserAttributes because they cannot be read.
  • Loading branch information
armsnyder committed Nov 23, 2020
1 parent dac1ed3 commit 80a156c
Showing 1 changed file with 43 additions and 55 deletions.
98 changes: 43 additions & 55 deletions gitlab/resource_gitlab_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ func TestAccGitlabUser_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckGitlabUserExists("gitlab_user.foo", &user),
testAccCheckGitlabUserAttributes(&user, &testAccGitlabUserExpectedAttributes{
Email: fmt.Sprintf("listest%d@ssss.com", rInt),
Password: fmt.Sprintf("test%dtt", rInt),
Username: fmt.Sprintf("listest%d", rInt),
Name: fmt.Sprintf("foo %d", rInt),
ProjectsLimit: 0,
Admin: false,
CanCreateGroup: false,
SkipConfirmation: true,
External: false,
Email: fmt.Sprintf("listest%d@ssss.com", rInt),
Username: fmt.Sprintf("listest%d", rInt),
Name: fmt.Sprintf("foo %d", rInt),
ProjectsLimit: 0,
Admin: false,
CanCreateGroup: false,
External: false,
}),
),
},
Expand All @@ -53,15 +51,13 @@ func TestAccGitlabUser_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckGitlabUserExists("gitlab_user.foo", &user),
testAccCheckGitlabUserAttributes(&user, &testAccGitlabUserExpectedAttributes{
Email: fmt.Sprintf("listest%d@tttt.com", rInt),
Password: fmt.Sprintf("test%dtt", rInt),
Username: fmt.Sprintf("listest%d", rInt),
Name: fmt.Sprintf("bar %d", rInt),
ProjectsLimit: 10,
Admin: true,
CanCreateGroup: true,
SkipConfirmation: true,
External: false,
Email: fmt.Sprintf("listest%d@tttt.com", rInt),
Username: fmt.Sprintf("listest%d", rInt),
Name: fmt.Sprintf("bar %d", rInt),
ProjectsLimit: 10,
Admin: true,
CanCreateGroup: true,
External: false,
}),
),
},
Expand All @@ -79,15 +75,13 @@ func TestAccGitlabUser_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckGitlabUserExists("gitlab_user.foo", &user),
testAccCheckGitlabUserAttributes(&user, &testAccGitlabUserExpectedAttributes{
Email: fmt.Sprintf("listest%d@ssss.com", rInt),
Password: fmt.Sprintf("test%dtt", rInt),
Username: fmt.Sprintf("listest%d", rInt),
Name: fmt.Sprintf("foo %d", rInt),
ProjectsLimit: 0,
Admin: false,
CanCreateGroup: false,
SkipConfirmation: true,
External: false,
Email: fmt.Sprintf("listest%d@ssss.com", rInt),
Username: fmt.Sprintf("listest%d", rInt),
Name: fmt.Sprintf("foo %d", rInt),
ProjectsLimit: 0,
Admin: false,
CanCreateGroup: false,
External: false,
}),
),
},
Expand All @@ -105,15 +99,13 @@ func TestAccGitlabUser_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckGitlabUserExists("gitlab_user.foo", &user),
testAccCheckGitlabUserAttributes(&user, &testAccGitlabUserExpectedAttributes{
Email: fmt.Sprintf("listest%d@ssss.com", rInt),
Password: fmt.Sprintf("test%dtt", rInt),
Username: fmt.Sprintf("listest%d", rInt),
Name: fmt.Sprintf("foo %d", rInt),
ProjectsLimit: 0,
Admin: false,
CanCreateGroup: false,
SkipConfirmation: false,
External: false,
Email: fmt.Sprintf("listest%d@ssss.com", rInt),
Username: fmt.Sprintf("listest%d", rInt),
Name: fmt.Sprintf("foo %d", rInt),
ProjectsLimit: 0,
Admin: false,
CanCreateGroup: false,
External: false,
}),
),
},
Expand All @@ -125,21 +117,19 @@ func TestAccGitlabUser_basic(t *testing.T) {
"password",
},
},
// Update the user to put the name back
// Update the user to initial config
{
Config: testAccGitlabUserConfig(rInt),
Check: resource.ComposeTestCheckFunc(
testAccCheckGitlabUserExists("gitlab_user.foo", &user),
testAccCheckGitlabUserAttributes(&user, &testAccGitlabUserExpectedAttributes{
Email: fmt.Sprintf("listest%d@ssss.com", rInt),
Password: fmt.Sprintf("test%dtt", rInt),
Username: fmt.Sprintf("listest%d", rInt),
Name: fmt.Sprintf("foo %d", rInt),
ProjectsLimit: 0,
Admin: false,
CanCreateGroup: false,
SkipConfirmation: true,
External: false,
Email: fmt.Sprintf("listest%d@ssss.com", rInt),
Username: fmt.Sprintf("listest%d", rInt),
Name: fmt.Sprintf("foo %d", rInt),
ProjectsLimit: 0,
Admin: false,
CanCreateGroup: false,
External: false,
}),
),
},
Expand Down Expand Up @@ -211,15 +201,13 @@ func testAccCheckGitlabUserExists(n string, user *gitlab.User) resource.TestChec
}

type testAccGitlabUserExpectedAttributes struct {
Email string
Password string
Username string
Name string
ProjectsLimit int
Admin bool
CanCreateGroup bool
SkipConfirmation bool
External bool
Email string
Username string
Name string
ProjectsLimit int
Admin bool
CanCreateGroup bool
External bool
}

func testAccCheckGitlabUserAttributes(user *gitlab.User, want *testAccGitlabUserExpectedAttributes) resource.TestCheckFunc {
Expand Down

0 comments on commit 80a156c

Please sign in to comment.