@@ -50,6 +50,7 @@ func TestAccGitlabProjectMembership_basic(t *testing.T) {
50
50
func testAccCheckGitlabProjectMembershipExists (n string , membership * gitlab.ProjectMember ) resource.TestCheckFunc {
51
51
return func (s * terraform.State ) error {
52
52
rs , ok := s .RootModule ().Resources [n ]
53
+ conn := testAccProvider .Meta ().(* gitlab.Client )
53
54
if ! ok {
54
55
return fmt .Errorf ("Not found: %s" , n )
55
56
}
@@ -59,15 +60,13 @@ func testAccCheckGitlabProjectMembershipExists(n string, membership *gitlab.Proj
59
60
return fmt .Errorf ("No project ID is set" )
60
61
}
61
62
62
- userID := rs .Primary .Attributes ["userID" ]
63
+ userID := rs .Primary .Attributes ["user_id" ]
64
+ id , _ := strconv .Atoi (userID )
63
65
if userID == "" {
64
66
return fmt .Errorf ("No user id is set" )
65
67
}
66
68
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 )
71
70
if err != nil {
72
71
return err
73
72
}
@@ -133,55 +132,45 @@ func testAccCheckGitlabProjectMembershipDestroy(s *terraform.State) error {
133
132
}
134
133
135
134
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
+ }
143
140
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
+ }
153
146
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 )
160
154
}
161
155
162
156
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
+ }
170
162
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
+ }
180
168
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 )
187
176
}
0 commit comments