@@ -25,14 +25,17 @@ func TestAccGitlabProject_basic(t *testing.T) {
2525 Check : resource .ComposeTestCheckFunc (
2626 testAccCheckGitlabProjectExists ("gitlab_project.foo" , & project ),
2727 testAccCheckGitlabProjectAttributes (& project , & testAccGitlabProjectExpectedAttributes {
28- Name : fmt .Sprintf ("foo-%d" , rInt ),
29- Path : fmt .Sprintf ("foo.%d" , rInt ),
30- Description : "Terraform acceptance tests" ,
31- IssuesEnabled : true ,
32- MergeRequestsEnabled : true ,
33- WikiEnabled : true ,
34- SnippetsEnabled : true ,
35- Visibility : gitlab .PublicVisibility ,
28+ Name : fmt .Sprintf ("foo-%d" , rInt ),
29+ Path : fmt .Sprintf ("foo.%d" , rInt ),
30+ Description : "Terraform acceptance tests" ,
31+ IssuesEnabled : true ,
32+ MergeRequestsEnabled : true ,
33+ WikiEnabled : true ,
34+ SnippetsEnabled : true ,
35+ Visibility : gitlab .PublicVisibility ,
36+ MergeMethod : gitlab .FastForwardMerge ,
37+ OnlyAllowMergeIfPipelineSucceeds : true ,
38+ OnlyAllowMergeIfAllDiscussionsAreResolved : true ,
3639 }),
3740 ),
3841 },
@@ -42,27 +45,33 @@ func TestAccGitlabProject_basic(t *testing.T) {
4245 Check : resource .ComposeTestCheckFunc (
4346 testAccCheckGitlabProjectExists ("gitlab_project.foo" , & project ),
4447 testAccCheckGitlabProjectAttributes (& project , & testAccGitlabProjectExpectedAttributes {
45- Name : fmt .Sprintf ("foo-%d" , rInt ),
46- Path : fmt .Sprintf ("foo.%d" , rInt ),
47- Description : "Terraform acceptance tests!" ,
48- Visibility : gitlab .PublicVisibility ,
48+ Name : fmt .Sprintf ("foo-%d" , rInt ),
49+ Path : fmt .Sprintf ("foo.%d" , rInt ),
50+ Description : "Terraform acceptance tests!" ,
51+ Visibility : gitlab .PublicVisibility ,
52+ MergeMethod : gitlab .FastForwardMerge ,
53+ OnlyAllowMergeIfPipelineSucceeds : true ,
54+ OnlyAllowMergeIfAllDiscussionsAreResolved : true ,
4955 }),
5056 ),
5157 },
52- //Update the project to turn the features on again
58+ // Update the project to turn the features on again
5359 {
5460 Config : testAccGitlabProjectConfig (rInt ),
5561 Check : resource .ComposeTestCheckFunc (
5662 testAccCheckGitlabProjectExists ("gitlab_project.foo" , & project ),
5763 testAccCheckGitlabProjectAttributes (& project , & testAccGitlabProjectExpectedAttributes {
58- Name : fmt .Sprintf ("foo-%d" , rInt ),
59- Path : fmt .Sprintf ("foo.%d" , rInt ),
60- Description : "Terraform acceptance tests" ,
61- IssuesEnabled : true ,
62- MergeRequestsEnabled : true ,
63- WikiEnabled : true ,
64- SnippetsEnabled : true ,
65- Visibility : gitlab .PublicVisibility ,
64+ Name : fmt .Sprintf ("foo-%d" , rInt ),
65+ Path : fmt .Sprintf ("foo.%d" , rInt ),
66+ Description : "Terraform acceptance tests" ,
67+ IssuesEnabled : true ,
68+ MergeRequestsEnabled : true ,
69+ WikiEnabled : true ,
70+ SnippetsEnabled : true ,
71+ Visibility : gitlab .PublicVisibility ,
72+ MergeMethod : gitlab .FastForwardMerge ,
73+ OnlyAllowMergeIfPipelineSucceeds : true ,
74+ OnlyAllowMergeIfAllDiscussionsAreResolved : true ,
6675 }),
6776 ),
6877 },
@@ -72,14 +81,17 @@ func TestAccGitlabProject_basic(t *testing.T) {
7281 Check : resource .ComposeTestCheckFunc (
7382 testAccCheckGitlabProjectExists ("gitlab_project.foo" , & project ),
7483 testAccCheckGitlabProjectAttributes (& project , & testAccGitlabProjectExpectedAttributes {
75- Name : fmt .Sprintf ("foo-%d" , rInt ),
76- Path : fmt .Sprintf ("foo.%d" , rInt ),
77- Description : "Terraform acceptance tests" ,
78- IssuesEnabled : true ,
79- MergeRequestsEnabled : true ,
80- WikiEnabled : true ,
81- SnippetsEnabled : true ,
82- Visibility : gitlab .PublicVisibility ,
84+ Name : fmt .Sprintf ("foo-%d" , rInt ),
85+ Path : fmt .Sprintf ("foo.%d" , rInt ),
86+ Description : "Terraform acceptance tests" ,
87+ IssuesEnabled : true ,
88+ MergeRequestsEnabled : true ,
89+ WikiEnabled : true ,
90+ SnippetsEnabled : true ,
91+ Visibility : gitlab .PublicVisibility ,
92+ MergeMethod : gitlab .FastForwardMerge ,
93+ OnlyAllowMergeIfPipelineSucceeds : false ,
94+ OnlyAllowMergeIfAllDiscussionsAreResolved : false ,
8395 SharedWithGroups : []struct {
8496 GroupID int
8597 GroupName string
@@ -94,14 +106,17 @@ func TestAccGitlabProject_basic(t *testing.T) {
94106 Check : resource .ComposeTestCheckFunc (
95107 testAccCheckGitlabProjectExists ("gitlab_project.foo" , & project ),
96108 testAccCheckGitlabProjectAttributes (& project , & testAccGitlabProjectExpectedAttributes {
97- Name : fmt .Sprintf ("foo-%d" , rInt ),
98- Path : fmt .Sprintf ("foo.%d" , rInt ),
99- Description : "Terraform acceptance tests" ,
100- IssuesEnabled : true ,
101- MergeRequestsEnabled : true ,
102- WikiEnabled : true ,
103- SnippetsEnabled : true ,
104- Visibility : gitlab .PublicVisibility ,
109+ Name : fmt .Sprintf ("foo-%d" , rInt ),
110+ Path : fmt .Sprintf ("foo.%d" , rInt ),
111+ Description : "Terraform acceptance tests" ,
112+ IssuesEnabled : true ,
113+ MergeRequestsEnabled : true ,
114+ WikiEnabled : true ,
115+ SnippetsEnabled : true ,
116+ Visibility : gitlab .PublicVisibility ,
117+ MergeMethod : gitlab .FastForwardMerge ,
118+ OnlyAllowMergeIfPipelineSucceeds : false ,
119+ OnlyAllowMergeIfAllDiscussionsAreResolved : false ,
105120 SharedWithGroups : []struct {
106121 GroupID int
107122 GroupName string
@@ -116,14 +131,17 @@ func TestAccGitlabProject_basic(t *testing.T) {
116131 Check : resource .ComposeTestCheckFunc (
117132 testAccCheckGitlabProjectExists ("gitlab_project.foo" , & project ),
118133 testAccCheckGitlabProjectAttributes (& project , & testAccGitlabProjectExpectedAttributes {
119- Name : fmt .Sprintf ("foo-%d" , rInt ),
120- Path : fmt .Sprintf ("foo.%d" , rInt ),
121- Description : "Terraform acceptance tests" ,
122- IssuesEnabled : true ,
123- MergeRequestsEnabled : true ,
124- WikiEnabled : true ,
125- SnippetsEnabled : true ,
126- Visibility : gitlab .PublicVisibility ,
134+ Name : fmt .Sprintf ("foo-%d" , rInt ),
135+ Path : fmt .Sprintf ("foo.%d" , rInt ),
136+ Description : "Terraform acceptance tests" ,
137+ IssuesEnabled : true ,
138+ MergeRequestsEnabled : true ,
139+ WikiEnabled : true ,
140+ SnippetsEnabled : true ,
141+ Visibility : gitlab .PublicVisibility ,
142+ MergeMethod : gitlab .FastForwardMerge ,
143+ OnlyAllowMergeIfPipelineSucceeds : true ,
144+ OnlyAllowMergeIfAllDiscussionsAreResolved : true ,
127145 SharedWithGroups : []struct {
128146 GroupID int
129147 GroupName string
@@ -199,16 +217,19 @@ func testAccCheckGitlabProjectExists(n string, project *gitlab.Project) resource
199217}
200218
201219type testAccGitlabProjectExpectedAttributes struct {
202- Name string
203- Path string
204- Description string
205- DefaultBranch string
206- IssuesEnabled bool
207- MergeRequestsEnabled bool
208- WikiEnabled bool
209- SnippetsEnabled bool
210- Visibility gitlab.VisibilityValue
211- SharedWithGroups []struct {
220+ Name string
221+ Path string
222+ Description string
223+ DefaultBranch string
224+ IssuesEnabled bool
225+ MergeRequestsEnabled bool
226+ WikiEnabled bool
227+ SnippetsEnabled bool
228+ Visibility gitlab.VisibilityValue
229+ MergeMethod gitlab.MergeMethodValue
230+ OnlyAllowMergeIfPipelineSucceeds bool
231+ OnlyAllowMergeIfAllDiscussionsAreResolved bool
232+ SharedWithGroups []struct {
212233 GroupID int
213234 GroupName string
214235 GroupAccessLevel int
@@ -257,6 +278,18 @@ func testAccCheckGitlabProjectAttributes(project *gitlab.Project, want *testAccG
257278 }
258279 }
259280
281+ if project .MergeMethod != want .MergeMethod {
282+ return fmt .Errorf ("got merge_method %q; want %q" , project .MergeMethod , want .MergeMethod )
283+ }
284+
285+ if project .OnlyAllowMergeIfPipelineSucceeds != want .OnlyAllowMergeIfPipelineSucceeds {
286+ return fmt .Errorf ("got only_allow_merge_if_pipeline_succeeds %t; want %t" , project .OnlyAllowMergeIfPipelineSucceeds , want .OnlyAllowMergeIfPipelineSucceeds )
287+ }
288+
289+ if project .OnlyAllowMergeIfAllDiscussionsAreResolved != want .OnlyAllowMergeIfAllDiscussionsAreResolved {
290+ return fmt .Errorf ("got only_allow_merge_if_all_discussions_are_resolved %t; want %t" , project .OnlyAllowMergeIfAllDiscussionsAreResolved , want .OnlyAllowMergeIfAllDiscussionsAreResolved )
291+ }
292+
260293 return nil
261294 }
262295}
@@ -313,6 +346,9 @@ resource "gitlab_project" "foo" {
313346 # So that acceptance tests can be run in a gitlab organization
314347 # with no billing
315348 visibility_level = "public"
349+ merge_method = "ff"
350+ only_allow_merge_if_pipeline_succeeds = true
351+ only_allow_merge_if_all_discussions_are_resolved = true
316352}
317353 ` , rInt , rInt )
318354}
@@ -327,6 +363,9 @@ resource "gitlab_project" "foo" {
327363 # So that acceptance tests can be run in a gitlab organization
328364 # with no billing
329365 visibility_level = "public"
366+ merge_method = "ff"
367+ only_allow_merge_if_pipeline_succeeds = true
368+ only_allow_merge_if_all_discussions_are_resolved = true
330369
331370 issues_enabled = false
332371 merge_requests_enabled = false
@@ -343,6 +382,9 @@ resource "gitlab_project" "foo" {
343382 path = "foo.%d"
344383 description = "Terraform acceptance tests"
345384 visibility_level = "public"
385+ merge_method = "ff"
386+ only_allow_merge_if_pipeline_succeeds = false
387+ only_allow_merge_if_all_discussions_are_resolved = false
346388
347389 shared_with_groups = [
348390 {
@@ -368,6 +410,9 @@ resource "gitlab_project" "foo" {
368410 path = "foo.%d"
369411 description = "Terraform acceptance tests"
370412 visibility_level = "public"
413+ merge_method = "ff"
414+ only_allow_merge_if_pipeline_succeeds = false
415+ only_allow_merge_if_all_discussions_are_resolved = false
371416
372417 shared_with_groups = [
373418 {
0 commit comments