From abf6939992049c9d54ee430e6289ead4303b027c Mon Sep 17 00:00:00 2001 From: Kaoru HAYAMA Date: Wed, 25 Oct 2017 13:47:36 +0900 Subject: [PATCH 1/3] Fix: Type of Notification.ID was int64. Change to ID --- notification.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notification.go b/notification.go index 15e6cf7..155e417 100644 --- a/notification.go +++ b/notification.go @@ -9,7 +9,7 @@ import ( // Notification hold information for mastodon notification. type Notification struct { - ID int64 `json:"id"` + ID ID `json:"id"` Type string `json:"type"` CreatedAt time.Time `json:"created_at"` Account Account `json:"account"` From 74f003d4a4cdb85187571c071955201deccd6fa0 Mon Sep 17 00:00:00 2001 From: Kaoru HAYAMA Date: Wed, 25 Oct 2017 14:24:00 +0900 Subject: [PATCH 2/3] Fix tests about notification.ID (which type was changed on #63) --- notification_test.go | 6 +++--- streaming_ws_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/notification_test.go b/notification_test.go index 740dec9..414ebff 100644 --- a/notification_test.go +++ b/notification_test.go @@ -39,17 +39,17 @@ func TestGetNotifications(t *testing.T) { if len(ns) != 2 { t.Fatalf("result should be two: %d", len(ns)) } - if ns[0].ID != 122 { + if ns[0].ID != "122" { t.Fatalf("want %v but %v", 122, ns[0].ID) } - if ns[1].ID != 123 { + if ns[1].ID != "123" { t.Fatalf("want %v but %v", 123, ns[1].ID) } n, err := client.GetNotification(context.Background(), 123) if err != nil { t.Fatalf("should not be fail: %v", err) } - if n.ID != 123 { + if n.ID != "123" { t.Fatalf("want %v but %v", 123, n.ID) } err = client.ClearNotifications(context.Background()) diff --git a/streaming_ws_test.go b/streaming_ws_test.go index f52477c..3c8974b 100644 --- a/streaming_ws_test.go +++ b/streaming_ws_test.go @@ -117,7 +117,7 @@ func wsTest(t *testing.T, q chan Event, cancel func()) { if events[0].(*UpdateEvent).Status.Content != "foo" { t.Fatalf("want %q but %q", "foo", events[0].(*UpdateEvent).Status.Content) } - if events[1].(*NotificationEvent).Notification.ID != 123 { + if events[1].(*NotificationEvent).Notification.ID != "123" { t.Fatalf("want %d but %d", 123, events[1].(*NotificationEvent).Notification.ID) } if events[2].(*DeleteEvent).ID != 1234567 { From fe913e01e56f7a0d1105126450f9ffe9a30e774b Mon Sep 17 00:00:00 2001 From: Kaoru HAYAMA Date: Wed, 25 Oct 2017 14:35:34 +0900 Subject: [PATCH 3/3] Fix: forgot to (*Client)GetNotification's parameter: int64 -> ID --- notification.go | 4 ++-- notification_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/notification.go b/notification.go index 155e417..0dfd8f8 100644 --- a/notification.go +++ b/notification.go @@ -27,9 +27,9 @@ func (c *Client) GetNotifications(ctx context.Context, pg *Pagination) ([]*Notif } // GetNotification return notification. -func (c *Client) GetNotification(ctx context.Context, id int64) (*Notification, error) { +func (c *Client) GetNotification(ctx context.Context, id ID) (*Notification, error) { var notification Notification - err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%d", id), nil, ¬ification, nil) + err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%v", id), nil, ¬ification, nil) if err != nil { return nil, err } diff --git a/notification_test.go b/notification_test.go index 414ebff..3329d02 100644 --- a/notification_test.go +++ b/notification_test.go @@ -40,17 +40,17 @@ func TestGetNotifications(t *testing.T) { t.Fatalf("result should be two: %d", len(ns)) } if ns[0].ID != "122" { - t.Fatalf("want %v but %v", 122, ns[0].ID) + t.Fatalf("want %v but %v", "122", ns[0].ID) } if ns[1].ID != "123" { - t.Fatalf("want %v but %v", 123, ns[1].ID) + t.Fatalf("want %v but %v", "123", ns[1].ID) } - n, err := client.GetNotification(context.Background(), 123) + n, err := client.GetNotification(context.Background(), "123") if err != nil { t.Fatalf("should not be fail: %v", err) } if n.ID != "123" { - t.Fatalf("want %v but %v", 123, n.ID) + t.Fatalf("want %v but %v", "123", n.ID) } err = client.ClearNotifications(context.Background()) if err != nil {