@@ -302,6 +302,56 @@ func TestAccGitlabProject_nestedImport(t *testing.T) {
302
302
})
303
303
}
304
304
305
+ func TestAccGitlabProject_transfer (t * testing.T ) {
306
+ var transferred , received gitlab.Project
307
+ rInt := acctest .RandInt ()
308
+
309
+ transferred = gitlab.Project {
310
+ Namespace : & gitlab.ProjectNamespace {Name : fmt .Sprintf ("foo2group-%d" , rInt )},
311
+ Name : fmt .Sprintf ("foo-%d" , rInt ),
312
+ Path : fmt .Sprintf ("foo-%d" , rInt ),
313
+ Description : "Terraform acceptance tests" ,
314
+ TagList : []string {},
315
+ RequestAccessEnabled : true ,
316
+ IssuesEnabled : true ,
317
+ MergeRequestsEnabled : true ,
318
+ JobsEnabled : true ,
319
+ ApprovalsBeforeMerge : 0 ,
320
+ WikiEnabled : true ,
321
+ SnippetsEnabled : true ,
322
+ ContainerRegistryEnabled : true ,
323
+ LFSEnabled : true ,
324
+ SharedRunnersEnabled : true ,
325
+ Visibility : gitlab .PublicVisibility ,
326
+ MergeMethod : gitlab .NoFastForwardMerge ,
327
+ OnlyAllowMergeIfPipelineSucceeds : false ,
328
+ OnlyAllowMergeIfAllDiscussionsAreResolved : false ,
329
+ }
330
+
331
+ resource .Test (t , resource.TestCase {
332
+ PreCheck : func () { testAccPreCheck (t ) },
333
+ Providers : testAccProviders ,
334
+ CheckDestroy : testAccCheckGitlabProjectDestroy ,
335
+ Steps : []resource.TestStep {
336
+ // Create a project in a group
337
+ {
338
+ Config : testAccGitlabProjectInGroupConfig (rInt ),
339
+ Check : resource .ComposeTestCheckFunc (
340
+ testAccCheckGitlabProjectExists ("gitlab_project.foo" , & received ),
341
+ ),
342
+ },
343
+ // Create a second group and set the transfer the project to this group
344
+ {
345
+ Config : testAccGitlabProjectTransferBetweenGroups (rInt ),
346
+ Check : resource .ComposeTestCheckFunc (
347
+ testAccCheckGitlabProjectExists ("gitlab_project.foo" , & received ),
348
+ testAccCheckAggregateGitlabProject (& transferred , & received ),
349
+ ),
350
+ },
351
+ },
352
+ })
353
+ }
354
+
305
355
func testAccCheckGitlabProjectExists (n string , project * gitlab.Project ) resource.TestCheckFunc {
306
356
return func (s * terraform.State ) error {
307
357
var err error
@@ -431,6 +481,32 @@ resource "gitlab_project" "foo" {
431
481
` , rInt , rInt , rInt )
432
482
}
433
483
484
+ func testAccGitlabProjectTransferBetweenGroups (rInt int ) string {
485
+ return fmt .Sprintf (`
486
+ resource "gitlab_group" "foo" {
487
+ name = "foogroup-%d"
488
+ path = "foogroup-%d"
489
+ visibility_level = "public"
490
+ }
491
+
492
+ resource "gitlab_group" "foo2" {
493
+ name = "foo2group-%d"
494
+ path = "foo2group-%d"
495
+ visibility_level = "public"
496
+ }
497
+
498
+ resource "gitlab_project" "foo" {
499
+ name = "foo-%d"
500
+ description = "Terraform acceptance tests"
501
+ namespace_id = "${gitlab_group.foo2.id}"
502
+
503
+ # So that acceptance tests can be run in a gitlab organization
504
+ # with no billing
505
+ visibility_level = "public"
506
+ }
507
+ ` , rInt , rInt , rInt , rInt , rInt )
508
+ }
509
+
434
510
func testAccGitlabProjectConfigDefaultBranch (rInt int , defaultBranch string ) string {
435
511
defaultBranchStatement := ""
436
512
0 commit comments