@@ -67,6 +67,46 @@ func TestAccGitlabProject_basic(t *testing.T) {
67
67
})
68
68
}
69
69
70
+ func TestAccGitlabProject_import (t * testing.T ) {
71
+ rInt := acctest .RandInt ()
72
+
73
+ resource .Test (t , resource.TestCase {
74
+ PreCheck : func () { testAccPreCheck (t ) },
75
+ Providers : testAccProviders ,
76
+ CheckDestroy : testAccCheckGitlabProjectDestroy ,
77
+ Steps : []resource.TestStep {
78
+ {
79
+ Config : testAccGitlabProjectConfig (rInt ),
80
+ },
81
+ {
82
+ ResourceName : "gitlab_project.foo" ,
83
+ ImportState : true ,
84
+ ImportStateVerify : true ,
85
+ },
86
+ },
87
+ })
88
+ }
89
+
90
+ func TestAccGitlabProject_nestedImport (t * testing.T ) {
91
+ rInt := acctest .RandInt ()
92
+
93
+ resource .Test (t , resource.TestCase {
94
+ PreCheck : func () { testAccPreCheck (t ) },
95
+ Providers : testAccProviders ,
96
+ CheckDestroy : testAccCheckGitlabProjectDestroy ,
97
+ Steps : []resource.TestStep {
98
+ {
99
+ Config : testAccGitlabProjectInGroupConfig (rInt ),
100
+ },
101
+ {
102
+ ResourceName : "gitlab_project.foo" ,
103
+ ImportState : true ,
104
+ ImportStateVerify : true ,
105
+ },
106
+ },
107
+ })
108
+ }
109
+
70
110
func testAccCheckGitlabProjectExists (n string , project * gitlab.Project ) resource.TestCheckFunc {
71
111
return func (s * terraform.State ) error {
72
112
rs , ok := s .RootModule ().Resources [n ]
@@ -159,6 +199,26 @@ func testAccCheckGitlabProjectDestroy(s *terraform.State) error {
159
199
return nil
160
200
}
161
201
202
+ func testAccGitlabProjectInGroupConfig (rInt int ) string {
203
+ return fmt .Sprintf (`
204
+ resource "gitlab_group" "foo" {
205
+ name = "foogroup-%d"
206
+ path = "foogroup-%d"
207
+ visibility_level = "public"
208
+ }
209
+
210
+ resource "gitlab_project" "foo" {
211
+ name = "foo-%d"
212
+ description = "Terraform acceptance tests"
213
+ namespace_id = "${gitlab_group.foo.id}"
214
+
215
+ # So that acceptance tests can be run in a gitlab organization
216
+ # with no billing
217
+ visibility_level = "public"
218
+ }
219
+ ` , rInt , rInt , rInt )
220
+ }
221
+
162
222
func testAccGitlabProjectConfig (rInt int ) string {
163
223
return fmt .Sprintf (`
164
224
resource "gitlab_project" "foo" {
0 commit comments