Skip to content

Commit 803978b

Browse files
shelley.besscehoffman
authored andcommitted
Configuration chages. testacc passes
Signed-off-by: shelley.bess <[email protected]>
1 parent e111140 commit 803978b

File tree

1 file changed

+38
-49
lines changed

1 file changed

+38
-49
lines changed

gitlab/resource_gitlab_project_membership_test.go

Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func TestAccGitlabProjectMembership_basic(t *testing.T) {
5050
func testAccCheckGitlabProjectMembershipExists(n string, membership *gitlab.ProjectMember) resource.TestCheckFunc {
5151
return func(s *terraform.State) error {
5252
rs, ok := s.RootModule().Resources[n]
53+
conn := testAccProvider.Meta().(*gitlab.Client)
5354
if !ok {
5455
return fmt.Errorf("Not found: %s", n)
5556
}
@@ -59,15 +60,13 @@ func testAccCheckGitlabProjectMembershipExists(n string, membership *gitlab.Proj
5960
return fmt.Errorf("No project ID is set")
6061
}
6162

62-
userID := rs.Primary.Attributes["userID"]
63+
userID := rs.Primary.Attributes["user_id"]
64+
id, _ := strconv.Atoi(userID)
6365
if userID == "" {
6466
return fmt.Errorf("No user id is set")
6567
}
6668

67-
conn := testAccProvider.Meta().(*gitlab.Client)
68-
69-
user_ID, err := strconv.Atoi(userID)
70-
gotProjectMembership, _, err := conn.ProjectMembers.GetProjectMember(projectID, user_ID)
69+
gotProjectMembership, _, err := conn.ProjectMembers.GetProjectMember(projectID, id)
7170
if err != nil {
7271
return err
7372
}
@@ -133,55 +132,45 @@ func testAccCheckGitlabProjectMembershipDestroy(s *terraform.State) error {
133132
}
134133

135134
func testAccGitlabProjectMembershipConfig(rInt int) string {
136-
return fmt.Sprintf(`resource "gitlab_project" "foo" {
137-
name = "foo-%d"
138-
description = "Terraform acceptance tests"
139-
140-
# So that acceptance tests can be run in a gitlab organziation with no billing
141-
visibility_level ="public"
142-
}
135+
return fmt.Sprintf(`resource "gitlab_project_membership" "foo" {
136+
project_id = "${gitlab_project.foo.id}"
137+
user_id = "${gitlab_user.test.id}"
138+
access_level = "developer"
139+
}
143140
144-
resource "gitlab_user" "foo" {
145-
name = "foo %d"
146-
username = "listest%d"
147-
password = "test%dtt"
148-
email = "listest%[email protected]"
149-
is_admin = false
150-
projects_limit = 20
151-
can_create_group = false
152-
}
141+
resource "gitlab_project" "foo" {
142+
name = "foo%d"
143+
description = "Terraform acceptance tests"
144+
visibility_level ="public"
145+
}
153146
154-
resource "gitlab_project_membership" "foo" {
155-
project_id = "${gitlab_project.foo.id}"
156-
user_id = "${gitlab_user.foo.id}"
157-
access_level = "developer"
158-
}
159-
`, rInt, rInt, rInt, rInt, rInt)
147+
resource "gitlab_user" "test" {
148+
name = "foo%d"
149+
username = "listest%d"
150+
password = "test%dtt"
151+
email = "listest%[email protected]"
152+
}
153+
`, rInt, rInt, rInt, rInt, rInt)
160154
}
161155

162156
func testAccGitlabProjectMembershipUpdateConfig(rInt int) string {
163-
return fmt.Sprintf(`resource "gitlab_project" "foo" {
164-
name = "foo-%d"
165-
description = Terraform acceptance tests"
166-
167-
# So that acceptance tests can be run in a gitlab organization with no billing
168-
visibility_level ="public"
169-
}
157+
return fmt.Sprintf(`resource "gitlab_project_membership" "foo" {
158+
project_id = "${gitlab_project.foo.id}"
159+
user_id = "${gitlab_user.test.id}"
160+
access_level = "guest"
161+
}
170162
171-
resource "gitlab_user" "foo" {
172-
name = "foo %d"
173-
username = "listest%d"
174-
password = "test%dtt"
175-
email = "listest%[email protected]"
176-
is_admin = false
177-
projects_limit = 20
178-
can_creat_group = false
179-
}
163+
resource "gitlab_project" "foo" {
164+
name = "foo%d"
165+
description = "Terraform acceptance tests"
166+
visibility_level ="public"
167+
}
180168
181-
resource "gitlab_project_membership" "foo" {
182-
project_id = "${gitlab_project.foo.id}"
183-
user_id = "${gitlab_user.foo.id}"
184-
access_level = "guest"
185-
}
186-
`, rInt, rInt, rInt, rInt, rInt)
169+
resource "gitlab_user" "test" {
170+
name = "foo%d"
171+
username = "listest%d"
172+
password = "test%dtt"
173+
email = "listest%[email protected]"
174+
}
175+
`, rInt, rInt, rInt, rInt, rInt)
187176
}

0 commit comments

Comments
 (0)