From 99a79d71a60bb32247dda7a92bca9e51b9e3e054 Mon Sep 17 00:00:00 2001 From: Adam Snyder Date: Mon, 23 Nov 2020 02:16:18 -0800 Subject: [PATCH] gitlab_user tests refactor: Remove Password and SkipConfirmation fields from testAccGitlabUserExpectedAttributes struct These fields were not being checked in testAccCheckGitlabUserAttributes because they cannot be read. --- gitlab/resource_gitlab_user_test.go | 98 +++++++++++++---------------- 1 file changed, 43 insertions(+), 55 deletions(-) diff --git a/gitlab/resource_gitlab_user_test.go b/gitlab/resource_gitlab_user_test.go index d4438a055..45679549c 100644 --- a/gitlab/resource_gitlab_user_test.go +++ b/gitlab/resource_gitlab_user_test.go @@ -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, }), ), }, @@ -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, }), ), }, @@ -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, }), ), }, @@ -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, }), ), }, @@ -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, }), ), }, @@ -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 {