@@ -238,3 +238,91 @@ func TestRepositoriesService_DeleteEnvironment(t *testing.T) {
238238 return client .Repositories .DeleteEnvironment (ctx , "o" , "r" , "e" )
239239 })
240240}
241+
242+ func TestRepoEnvironment_Marshal (t * testing.T ) {
243+ testJSONMarshal (t , & EnvResponse {}, "{}" )
244+
245+ repoEnv := & EnvResponse {
246+ TotalCount : Int (1 ),
247+ Environments : []* Environment {
248+ {
249+ Owner : String ("me" ),
250+ Repo : String ("se" ),
251+ EnvironmentName : String ("dev" ),
252+ WaitTimer : Int (123 ),
253+ Reviewers : []* EnvReviewers {
254+ {
255+ Type : String ("main" ),
256+ ID : Int64 (1 ),
257+ },
258+ {
259+ Type : String ("rev" ),
260+ ID : Int64 (2 ),
261+ },
262+ },
263+ DeploymentBranchPolicy : & BranchPolicy {
264+ ProtectedBranches : Bool (false ),
265+ CustomBranchPolicies : Bool (false ),
266+ },
267+ ID : Int64 (2 ),
268+ NodeID : String ("star" ),
269+ Name : String ("eg" ),
270+ URL : String ("https://hey.in" ),
271+ HTMLURL : String ("htmlurl" ),
272+ CreatedAt : & Timestamp {referenceTime },
273+ UpdatedAt : & Timestamp {referenceTime },
274+ ProtectionRules : []* ProtectionRule {
275+ {
276+ ID : Int64 (21 ),
277+ NodeID : String ("mnb" ),
278+ Type : String ("ewq" ),
279+ WaitTimer : Int (9090 ),
280+ },
281+ },
282+ },
283+ },
284+ }
285+
286+ want := `{
287+ "total_count":1,
288+ "environments":[
289+ {
290+ "owner":"me",
291+ "repo":"se",
292+ "environment_name":"dev",
293+ "wait_timer":123,
294+ "reviewers":[
295+ {
296+ "type":"main",
297+ "id":1
298+ },
299+ {
300+ "type":"rev",
301+ "id":2
302+ }
303+ ],
304+ "deployment_branch_policy":{
305+ "protected_branches":false,
306+ "custom_branch_policies":false
307+ },
308+ "id":2,
309+ "node_id":"star",
310+ "name":"eg",
311+ "url":"https://hey.in",
312+ "html_url":"htmlurl",
313+ "created_at":` + referenceTimeStr + `,
314+ "updated_at":` + referenceTimeStr + `,
315+ "protection_rules":[
316+ {
317+ "id":21,
318+ "node_id":"mnb",
319+ "type":"ewq",
320+ "wait_timer":9090
321+ }
322+ ]
323+ }
324+ ]
325+ }`
326+
327+ testJSONMarshal (t , repoEnv , want )
328+ }
0 commit comments