From a55d7cac41e69b84d2a2167759a3f9ddd6efa4f1 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Thu, 24 Jun 2021 18:04:45 +0530 Subject: [PATCH 1/3] Resource Tested for JSON marshalling : Notification --- github/activity_notifications_test.go | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index bce2136a3b9..663083a9095 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -312,3 +312,49 @@ func TestActivityService_DeleteThreadSubscription(t *testing.T) { return client.Activity.DeleteThreadSubscription(ctx, "1") }) } + +func TestNotification_Marshal(t *testing.T) { + testJSONMarshal(t, &Notification{}, "{}") + + u := &Notification{ + ID: String("id"), + Repository: &Repository{ + ID: Int64(1), + URL: String("u"), + Name: String("n"), + }, + Subject: &NotificationSubject{ + Title: String("t"), + URL: String("u"), + LatestCommentURL: String("l"), + Type: String("t"), + }, + Reason: String("r"), + Unread: Bool(true), + UpdatedAt: &referenceTime, + LastReadAt: &referenceTime, + URL: String("u"), + } + + want := `{ + "id": "id", + "repository": { + "id": 1, + "url": "u", + "name": "n" + }, + "subject": { + "title": "t", + "url": "u", + "latest_comment_url": "l", + "type": "t" + }, + "reason": "r", + "unread": true, + "updated_at": ` + referenceTimeStr + `, + "last_read_at": ` + referenceTimeStr + `, + "url": "u" + }` + + testJSONMarshal(t, u, want) +} From d964f15dc1399e6fe491137c43e586bc579f24a1 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Thu, 24 Jun 2021 18:14:49 +0530 Subject: [PATCH 2/3] Resource Tested for JSON Marshalling: NotificationSubject --- github/activity_notifications_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index 663083a9095..266357c55cb 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -358,3 +358,23 @@ func TestNotification_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestNotificationSubject_Marshal(t *testing.T) { + testJSONMarshal(t, &NotificationSubject{}, "{}") + + u := &NotificationSubject{ + Title: String("t"), + URL: String("u"), + LatestCommentURL: String("l"), + Type: String("t"), + } + + want := `{ + "title": "t", + "url": "u", + "latest_comment_url": "l", + "type": "t" + }` + + testJSONMarshal(t, u, want) +} From 5b89671ecfafbdd226aa458eb54776ccfdf24a78 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Thu, 24 Jun 2021 18:16:27 +0530 Subject: [PATCH 3/3] Resource Tested for JSON marshalling : markReadOptions --- github/activity_notifications_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index 266357c55cb..f46a12f474f 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -378,3 +378,17 @@ func TestNotificationSubject_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestMarkReadOptions_Marshal(t *testing.T) { + testJSONMarshal(t, &markReadOptions{}, "{}") + + u := &markReadOptions{ + LastReadAt: referenceTime, + } + + want := `{ + "last_read_at": ` + referenceTimeStr + ` + }` + + testJSONMarshal(t, u, want) +}