diff --git a/internal/app/notifications.go b/internal/app/notifications.go index 4b819732..bf8d4482 100644 --- a/internal/app/notifications.go +++ b/internal/app/notifications.go @@ -95,7 +95,11 @@ func (a *application) notificationCommand() *cobra.Command { return s.Mark(cmd.Context(), id, mark.status) }, func(item services.Notification) string { return fmt.Sprintf(mark.done, notificationLabel(item)) }) } - what := notificationsWith(filters) + " " + s.where + what := notificationsWith(filters) + if !until.IsZero() { + what += " updated before " + until.Format("2006-01-02 15:04") + } + what += " " + s.where if a.canPrompt() { if err := a.confirmAction(cmd, terminal.Confirmation{Prompt: fmt.Sprintf(mark.ask, what), DefaultYes: true}); err != nil { return err diff --git a/internal/app/notifications_test.go b/internal/app/notifications_test.go index 8c63a8e9..b961c8d7 100644 --- a/internal/app/notifications_test.go +++ b/internal/app/notifications_test.go @@ -143,3 +143,15 @@ func TestNotificationMutationsReportWhatChanged(t *testing.T) { require.Contains(t, withoutANSI(out.String()), "Latest comment: bob\n\n Looks good to me\n\nView this pull request on Gitea: https://gitea.test/alice/project/pulls/17\n") require.Equal(t, []string{"read"}, marks, "viewing marks an unread notification as read") } + +func TestNotificationMarkAllNamesTheBeforeCutoff(t *testing.T) { + now := time.Date(2028, 2, 1, 12, 0, 0, 0, time.UTC) + server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + _, _ = w.Write([]byte(`[]`)) + })) + defer server.Close() + deps, _, diagnostics := serverDeps(t, server.URL) + deps.Now = func() time.Time { return now } + require.NoError(t, Execute(context.Background(), deps, []string{"notification", "mark-read", "--all", "--before=1h"})) + require.Contains(t, withoutANSI(diagnostics.String()), "No unread notifications updated before 2028-02-01 11:00 in your inbox") +}