(t *testing.T)
| 168 | } |
| 169 | |
| 170 | func TestKeepList_JSON(t *testing.T) { |
| 171 | home := t.TempDir() |
| 172 | t.Setenv("HOME", home) |
| 173 | t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, "xdg-config")) |
| 174 | |
| 175 | account := "a@b.com" |
| 176 | _ = writeKeepSA(t) |
| 177 | |
| 178 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 179 | switch r.URL.Path { |
| 180 | case "/v1/notes": |
| 181 | _, _ = io.WriteString(w, `{"notes":[{"name":"notes/abc","title":"T","updateTime":"2026-01-01T00:00:00Z"}],"nextPageToken":"p2"}`) |
| 182 | return |
| 183 | default: |
| 184 | http.NotFound(w, r) |
| 185 | } |
| 186 | })) |
| 187 | t.Cleanup(srv.Close) |
| 188 | |
| 189 | svc := newKeepTestServiceFromServer(t, srv) |
| 190 | result := executeWithKeepTestService(t, []string{"--json", "keep", "list", "--account", account}, svc) |
| 191 | if result.err != nil { |
| 192 | t.Fatalf("Execute: %v\nstderr=%q", result.err, result.stderr) |
| 193 | } |
| 194 | |
| 195 | var payload struct { |
| 196 | Notes []any `json:"notes"` |
| 197 | NextPageToken string `json:"nextPageToken"` |
| 198 | } |
| 199 | if err := json.Unmarshal([]byte(result.stdout), &payload); err != nil { |
| 200 | t.Fatalf("json parse: %v\nout=%q", err, result.stdout) |
| 201 | } |
| 202 | if len(payload.Notes) != 1 || payload.NextPageToken != "p2" { |
| 203 | t.Fatalf("unexpected payload: %#v", payload) |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | func TestKeepGet_Plain(t *testing.T) { |
| 208 | home := t.TempDir() |
nothing calls this directly
no test coverage detected