Commit aa02c5e909
Verified · cmc
Layout: unified · split
internal/control/notifications.go +1 −1
| @@ -279,7 +279,7 @@ func runNotificationsDeviceAdd(c *Ctx, args []string) int { | |||
| 279 | return c.fail(protocol.ExitFailure, "%v", err) | 279 | return c.fail(protocol.ExitFailure, "%v", err) |
| 280 | } | 280 | } |
| 281 | return c.emit(map[string]any{"id": id, "status": "registered"}, func(w io.Writer) { | 281 | return c.emit(map[string]any{"id": id, "status": "registered"}, func(w io.Writer) { |
| 282 | fmt.Fprintf(w, "device %d registered\n", id) | 282 | fmt.Fprintf(w, "registered device %d\n", id) |
| 283 | }) | 283 | }) |
| 284 | } | 284 | } |
| 285 | 285 | ||
internal/control/notifications_test.go +13
| @@ -243,6 +243,19 @@ func TestNotificationsDeviceAddReturnsTheID(t *testing.T) { | |||
| 243 | } | 243 | } |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | func TestNotificationsDeviceAddPlainSaysRegisteredDevice(t *testing.T) { | ||
| 247 | c := notifTestCtx(t, "alice") | ||
| 248 | c.Stdin = strings.NewReader("DEVTOKEN\n") | ||
| 249 | var out bytes.Buffer | ||
| 250 | c.Stdout, c.JSON = &out, false | ||
| 251 | if code := runNotificationsDeviceAdd(c, nil); code != 0 { | ||
| 252 | t.Fatalf("exit %d", code) | ||
| 253 | } | ||
| 254 | if got := out.String(); !strings.HasPrefix(got, "registered device ") { | ||
| 255 | t.Errorf("device add printed %q", got) | ||
| 256 | } | ||
| 257 | } | ||
| 258 | |||
| 246 | func TestNotificationsSettingsShowsPush(t *testing.T) { | 259 | func TestNotificationsSettingsShowsPush(t *testing.T) { |
| 247 | c := notifTestCtx(t, "alice") | 260 | c := notifTestCtx(t, "alice") |
| 248 | var out bytes.Buffer | 261 | var out bytes.Buffer |