From 701a0b11160a6ae9d28c3eee1545ccaa2ab71704 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Wed, 7 Jul 2021 11:03:13 +0530 Subject: [PATCH] Resource Tested for JSON marshalling : Alert --- github/code-scanning_test.go | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index be9fb3de4c3..0432bc174d2 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -194,3 +194,51 @@ func TestActionsService_GetAlert(t *testing.T) { return resp, err }) } + +func TestAlert_Marshal(t *testing.T) { + testJSONMarshal(t, &Alert{}, "{}") + + u := &Alert{ + RuleID: String("rid"), + RuleSeverity: String("rs"), + RuleDescription: String("rd"), + Tool: String("t"), + CreatedAt: &Timestamp{referenceTime}, + Open: Bool(false), + ClosedBy: &User{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + URL: String("u"), + ReposURL: String("r"), + EventsURL: String("e"), + AvatarURL: String("a"), + }, + ClosedAt: &Timestamp{referenceTime}, + URL: String("url"), + HTMLURL: String("hurl"), + } + + want := `{ + "rule_id": "rid", + "rule_severity": "rs", + "rule_description": "rd", + "tool": "t", + "created_at": ` + referenceTimeStr + `, + "open": false, + "closed_by": { + "login": "l", + "id": 1, + "node_id": "n", + "avatar_url": "a", + "url": "u", + "events_url": "e", + "repos_url": "r" + }, + "closed_at": ` + referenceTimeStr + `, + "url": "url", + "html_url": "hurl" + }` + + testJSONMarshal(t, u, want) +}