Commit 3815908c8f
Verified · cmc
Layout: unified · split
internal/control/notifications.go +3 −1
| @@ -421,7 +421,9 @@ func runNotificationsList(c *Ctx, args []string) int { | ||
| 421 | 421 | if !c.JSON && !p.active && len(ds) == 0 { |
| 422 | 422 | msg := "nothing to list" |
| 423 | 423 | if !all { |
| 424 | msg = "no unread notifications (--all for read ones)" | |
| 424 | if read, err := c.Store.Inbox(c.User.ID, false, 1, 0); err == nil && len(read) > 0 { | |
| 425 | msg = "no unread notifications (--all for read ones)" | |
| 426 | } | |
| 425 | 427 | } |
| 426 | 428 | fmt.Fprintln(c.Stderr, msg) |
| 427 | 429 | return protocol.ExitOK |
internal/control/notifications_test.go +12
| @@ -270,6 +270,18 @@ func TestNotificationsSettingsShowsPush(t *testing.T) { | ||
| 270 | 270 | |
| 271 | 271 | func TestNotificationsListEmptyUnreadSaysHowToSeeRead(t *testing.T) { |
| 272 | 272 | c, repo, bob := testRepoWithWatcher(t) |
| 273 | // An inbox with nothing in it at all keeps the plain message. | |
| 274 | var empty bytes.Buffer | |
| 275 | alice := c.User | |
| 276 | c.User = store.User{ID: bob, Username: "bob"} | |
| 277 | c.Stdout, c.Stderr = &bytes.Buffer{}, &empty | |
| 278 | if code := runNotificationsList(c, nil); code != protocol.ExitOK { | |
| 279 | t.Fatalf("exit %d: %s", code, empty.String()) | |
| 280 | } | |
| 281 | if got := empty.String(); got != "nothing to list\n" { | |
| 282 | t.Errorf("empty inbox stderr = %q", got) | |
| 283 | } | |
| 284 | c.User = alice | |
| 273 | 285 | // Give bob one notice (acting as alice, so bob isn't filtered out as |
| 274 | 286 | // the actor), then mark it read as bob, so his inbox has rows but no |
| 275 | 287 | // unread ones. |