@@ -42,7 +42,24 @@ func TestListEnvironments(t *testing.T) {
4242 "external_url": "https://review-fix-foo-dfjre3.example.gitlab.com",
4343 "state": "stopped",
4444 "created_at": "2013-10-02T10:12:29Z",
45- "updated_at": "2013-12-02T10:12:29Z"
45+ "updated_at": "2013-12-02T10:12:29Z",
46+ "cluster_agent": {
47+ "id": 1,
48+ "name": "agent-1",
49+ "config_project": {
50+ "id": 20,
51+ "description": "",
52+ "name": "test",
53+ "name_with_namespace": "Administrator / test",
54+ "path": "test",
55+ "path_with_namespace": "root/test",
56+ "created_at": "2013-10-02T10:12:29Z"
57+ },
58+ "created_at": "2013-10-02T10:12:29Z",
59+ "created_by_user_id": 42
60+ },
61+ "kubernetes_namespace": "flux-system",
62+ "flux_resource_path": "HelmRelease/flux-system"
4663 }
4764 ]` )
4865 })
@@ -62,6 +79,22 @@ func TestListEnvironments(t *testing.T) {
6279 State : "stopped" ,
6380 CreatedAt : & createdAtWant ,
6481 UpdatedAt : & updatedAtWant ,
82+ ClusterAgent : & Agent {
83+ ID : 1 ,
84+ Name : "agent-1" ,
85+ ConfigProject : ConfigProject {
86+ ID : 20 ,
87+ Name : "test" ,
88+ NameWithNamespace : "Administrator / test" ,
89+ Path : "test" ,
90+ PathWithNamespace : "root/test" ,
91+ CreatedAt : & createdAtWant ,
92+ },
93+ CreatedAt : & createdAtWant ,
94+ CreatedByUserID : 42 ,
95+ },
96+ KubernetesNamespace : "flux-system" ,
97+ FluxResourcePath : "HelmRelease/flux-system" ,
6598 }}
6699 if ! reflect .DeepEqual (want , envs ) {
67100 t .Errorf ("Environments.ListEnvironments returned %+v, want %+v" , envs , want )
@@ -80,7 +113,24 @@ func TestGetEnvironment(t *testing.T) {
80113 "external_url": "https://review-fix-foo-dfjre3.example.gitlab.com",
81114 "state": "stopped",
82115 "created_at": "2013-10-02T10:12:29Z",
83- "updated_at": "2013-12-02T10:12:29Z"
116+ "updated_at": "2013-12-02T10:12:29Z",
117+ "cluster_agent": {
118+ "id": 1,
119+ "name": "agent-1",
120+ "config_project": {
121+ "id": 20,
122+ "description": "",
123+ "name": "test",
124+ "name_with_namespace": "Administrator / test",
125+ "path": "test",
126+ "path_with_namespace": "root/test",
127+ "created_at": "2013-10-02T10:12:29Z"
128+ },
129+ "created_at": "2013-10-02T10:12:29Z",
130+ "created_by_user_id": 42
131+ },
132+ "kubernetes_namespace": "flux-system",
133+ "flux_resource_path": "HelmRelease/flux-system"
84134 }` )
85135 })
86136
@@ -99,6 +149,22 @@ func TestGetEnvironment(t *testing.T) {
99149 State : "stopped" ,
100150 CreatedAt : & createdAtWant ,
101151 UpdatedAt : & updatedAtWant ,
152+ ClusterAgent : & Agent {
153+ ID : 1 ,
154+ Name : "agent-1" ,
155+ ConfigProject : ConfigProject {
156+ ID : 20 ,
157+ Name : "test" ,
158+ NameWithNamespace : "Administrator / test" ,
159+ Path : "test" ,
160+ PathWithNamespace : "root/test" ,
161+ CreatedAt : & createdAtWant ,
162+ },
163+ CreatedAt : & createdAtWant ,
164+ CreatedByUserID : 42 ,
165+ },
166+ KubernetesNamespace : "flux-system" ,
167+ FluxResourcePath : "HelmRelease/flux-system" ,
102168 }
103169 if ! reflect .DeepEqual (want , env ) {
104170 t .Errorf ("Environments.GetEnvironment returned %+v, want %+v" , env , want )
@@ -116,16 +182,63 @@ func TestCreateEnvironment(t *testing.T) {
116182 "name": "deploy",
117183 "slug": "deploy",
118184 "external_url": "https://deploy.example.gitlab.com",
119- "tier": "production"
185+ "tier": "production",
186+ "cluster_agent": {
187+ "id": 1,
188+ "name": "agent-1",
189+ "config_project": {
190+ "id": 20,
191+ "description": "",
192+ "name": "test",
193+ "name_with_namespace": "Administrator / test",
194+ "path": "test",
195+ "path_with_namespace": "root/test",
196+ "created_at": "2013-10-02T10:12:29Z"
197+ },
198+ "created_at": "2013-10-02T10:12:29Z",
199+ "created_by_user_id": 42
200+ },
201+ "kubernetes_namespace": "flux-system",
202+ "flux_resource_path": "HelmRelease/flux-system"
120203 }` )
121204 })
122205
123- envs , _ , err := client .Environments .CreateEnvironment (1 , & CreateEnvironmentOptions {Name : Ptr ("deploy" ), ExternalURL : Ptr ("https://deploy.example.gitlab.com" ), Tier : Ptr ("production" )})
206+ envs , _ , err := client .Environments .CreateEnvironment (1 , & CreateEnvironmentOptions {
207+ Name : Ptr ("deploy" ),
208+ ExternalURL : Ptr ("https://deploy.example.gitlab.com" ),
209+ Tier : Ptr ("production" ),
210+ ClusterAgentID : Ptr (1 ),
211+ KubernetesNamespace : Ptr ("flux-system" ),
212+ FluxResourcePath : Ptr ("HelmRelease/flux-system" ),
213+ })
124214 if err != nil {
125215 log .Fatal (err )
126216 }
127217
128- want := & Environment {ID : 1 , Name : "deploy" , Slug : "deploy" , ExternalURL : "https://deploy.example.gitlab.com" , Tier : "production" }
218+ createdAtWant , _ := time .Parse (timeLayout , "2013-10-02T10:12:29Z" )
219+ want := & Environment {
220+ ID : 1 ,
221+ Name : "deploy" ,
222+ Slug : "deploy" ,
223+ ExternalURL : "https://deploy.example.gitlab.com" ,
224+ Tier : "production" ,
225+ ClusterAgent : & Agent {
226+ ID : 1 ,
227+ Name : "agent-1" ,
228+ ConfigProject : ConfigProject {
229+ ID : 20 ,
230+ Name : "test" ,
231+ NameWithNamespace : "Administrator / test" ,
232+ Path : "test" ,
233+ PathWithNamespace : "root/test" ,
234+ CreatedAt : & createdAtWant ,
235+ },
236+ CreatedAt : & createdAtWant ,
237+ CreatedByUserID : 42 ,
238+ },
239+ KubernetesNamespace : "flux-system" ,
240+ FluxResourcePath : "HelmRelease/flux-system" ,
241+ }
129242 if ! reflect .DeepEqual (want , envs ) {
130243 t .Errorf ("Environments.CreateEnvironment returned %+v, want %+v" , envs , want )
131244 }
@@ -142,16 +255,63 @@ func TestEditEnvironment(t *testing.T) {
142255 "name": "staging",
143256 "slug": "staging",
144257 "external_url": "https://staging.example.gitlab.com",
145- "tier": "staging"
258+ "tier": "staging",
259+ "cluster_agent": {
260+ "id": 1,
261+ "name": "agent-1",
262+ "config_project": {
263+ "id": 20,
264+ "description": "",
265+ "name": "test",
266+ "name_with_namespace": "Administrator / test",
267+ "path": "test",
268+ "path_with_namespace": "root/test",
269+ "created_at": "2013-10-02T10:12:29Z"
270+ },
271+ "created_at": "2013-10-02T10:12:29Z",
272+ "created_by_user_id": 42
273+ },
274+ "kubernetes_namespace": "flux-system",
275+ "flux_resource_path": "HelmRelease/flux-system"
146276 }` )
147277 })
148278
149- envs , _ , err := client .Environments .EditEnvironment (1 , 1 , & EditEnvironmentOptions {Name : Ptr ("staging" ), ExternalURL : Ptr ("https://staging.example.gitlab.com" ), Tier : Ptr ("staging" )})
279+ envs , _ , err := client .Environments .EditEnvironment (1 , 1 , & EditEnvironmentOptions {
280+ Name : Ptr ("staging" ),
281+ ExternalURL : Ptr ("https://staging.example.gitlab.com" ),
282+ Tier : Ptr ("staging" ),
283+ ClusterAgentID : Ptr (1 ),
284+ KubernetesNamespace : Ptr ("flux-system" ),
285+ FluxResourcePath : Ptr ("HelmRelease/flux-system" ),
286+ })
150287 if err != nil {
151288 log .Fatal (err )
152289 }
153290
154- want := & Environment {ID : 1 , Name : "staging" , Slug : "staging" , ExternalURL : "https://staging.example.gitlab.com" , Tier : "staging" }
291+ createdAtWant , _ := time .Parse (timeLayout , "2013-10-02T10:12:29Z" )
292+ want := & Environment {
293+ ID : 1 ,
294+ Name : "staging" ,
295+ Slug : "staging" ,
296+ ExternalURL : "https://staging.example.gitlab.com" ,
297+ Tier : "staging" ,
298+ ClusterAgent : & Agent {
299+ ID : 1 ,
300+ Name : "agent-1" ,
301+ ConfigProject : ConfigProject {
302+ ID : 20 ,
303+ Name : "test" ,
304+ NameWithNamespace : "Administrator / test" ,
305+ Path : "test" ,
306+ PathWithNamespace : "root/test" ,
307+ CreatedAt : & createdAtWant ,
308+ },
309+ CreatedAt : & createdAtWant ,
310+ CreatedByUserID : 42 ,
311+ },
312+ KubernetesNamespace : "flux-system" ,
313+ FluxResourcePath : "HelmRelease/flux-system" ,
314+ }
155315 if ! reflect .DeepEqual (want , envs ) {
156316 t .Errorf ("Environments.EditEnvironment returned %+v, want %+v" , envs , want )
157317 }
0 commit comments