Commit aa02c5e909
aa02c5e909d34aeb6e7f9e314530495ceab29b3e
parent: 8eb3623130
Verified · cmc
cmc <hello@cleberg.net> · 2026-09-24 00:45 UTC
notifications device add: verb first
Ref #254
internal/control/notifications.go
+1 −1
| @@ -279,7 +279,7 @@ func runNotificationsDeviceAdd(c *Ctx, args []string) int { |
| 279 | 279 | return c.fail(protocol.ExitFailure, "%v", err) |
| 280 | 280 | } |
| 281 | 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 | 259 | func TestNotificationsSettingsShowsPush(t *testing.T) { |
| 247 | 260 | c := notifTestCtx(t, "alice") |
| 248 | 261 | var out bytes.Buffer |