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