Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ linters:
ignore-rules:
- analyses # returned by the GitHub API
- cancelled # returned by the GitHub API
modernize:
disable:
- omitzero # TODO: fix
nolintlint:
allow-unused: true
require-specific: true
Expand Down
4 changes: 3 additions & 1 deletion github/activity_notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ func (s *ActivityService) ListRepositoryNotifications(ctx context.Context, owner
}

type markReadOptions struct {
LastReadAt Timestamp `json:"last_read_at,omitempty"`
LastReadAt Timestamp `json:"last_read_at,omitzero"`
}

// MarkNotificationsRead marks all notifications up to lastRead as read.
// If lastRead is the zero value, all notifications in the repository are marked as read.
//
// GitHub API docs: https://docs.github.com/rest/activity/notifications#mark-notifications-as-read
//
Expand All @@ -123,6 +124,7 @@ func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead Ti

// MarkRepositoryNotificationsRead marks all notifications up to lastRead in
// the specified repository as read.
// If lastRead is the zero value, all notifications in the repository are marked as read.
//
// GitHub API docs: https://docs.github.com/rest/activity/notifications#mark-repository-notifications-as-read
//
Expand Down
38 changes: 38 additions & 0 deletions github/activity_notifications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,25 @@ func TestActivityService_MarkNotificationsRead(t *testing.T) {
})
}

func TestActivityService_MarkNotificationsRead_EmptyLastReadAt(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
testHeader(t, r, "Content-Type", "application/json")
testBody(t, r, `{}`+"\n")

w.WriteHeader(http.StatusResetContent)
})

ctx := t.Context()
_, err := client.Activity.MarkNotificationsRead(ctx, Timestamp{})
if err != nil {
t.Errorf("Activity.MarkNotificationsRead returned error: %v", err)
}
}

func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)
Expand Down Expand Up @@ -146,6 +165,25 @@ func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) {
})
}

func TestActivityService_MarkRepositoryNotificationsRead_EmptyLastReadAt(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
testHeader(t, r, "Content-Type", "application/json")
testBody(t, r, `{}`+"\n")

w.WriteHeader(http.StatusResetContent)
})

ctx := t.Context()
_, err := client.Activity.MarkRepositoryNotificationsRead(ctx, "o", "r", Timestamp{})
if err != nil {
t.Errorf("Activity.MarkRepositoryNotificationsRead returned error: %v", err)
}
}

func TestActivityService_GetThread(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)
Expand Down
2 changes: 1 addition & 1 deletion github/repos_contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type RepositoryContent struct {
// RepositoryContentResponse holds the parsed response from CreateFile, UpdateFile, and DeleteFile.
type RepositoryContentResponse struct {
Content *RepositoryContent `json:"content,omitempty"`
Commit `json:"commit,omitempty"`
Commit `json:"commit"`
}

// RepositoryContentFileOptions specifies optional parameters for CreateFile, UpdateFile, and DeleteFile.
Expand Down
Loading