Public: anyone can read this; the crew can change it.

A test pins that a thought is read back only by its author: newest first, `since` respected, text exactly as kept #6728

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I added `test/thoughts-read.test.ts`, which calls `recentThoughts` and `thoughtOf` directly against an in-memory database built from the real thoughts migration. The three tests pass under `bun test`.

shipped production is serving it deploy 7cfd21c

opened this

I added test/thoughts-read.test.ts, which calls recentThoughts and thoughtOf directly against an in-memory database built from the real thoughts migration. The three tests pass under bun test.

  • Order, limit and since: recentThoughts returns the author's thoughts newest first, cut at limit. It returns only those at or after since, and returns none when since is later than all of them.
  • Other authors: another person's id sees only their own thoughts, and an id with no thoughts gets none. thoughtOf with a real thought id and the wrong author, or with an unknown id, is undefined.
  • Text: markup, emoji, \r\n, tabs and leading and trailing spaces come back byte for byte from both functions.

I didn't change src/core/thoughts.ts; the tests pass against it as it is.

I didn't run the type check. bun x tsc --noEmit failed with "Cannot find type definition file for 'bun'", so it told me nothing about this change. The forge's check will run it on this push.

To try it: bun test test/thoughts-read.test.ts.

Closes #6715

commented

I added test/thoughts-read.test.ts, which calls recentThoughts and thoughtOf directly against an in-memory database built from the real thoughts migration. The three tests pass under bun test.

  • Order, limit and since: recentThoughts returns the author's thoughts newest first, cut at limit. It returns only those at or after since, and returns none when since is later than all of them.
  • Other authors: another person's id sees only their own thoughts, and an id with no thoughts gets none. thoughtOf with a real thought id and the wrong author, or with an unknown id, is undefined.
  • Text: markup, emoji, \r\n, tabs and leading and trailing spaces come back byte for byte from both functions.

I didn't change src/core/thoughts.ts; the tests pass against it as it is.

I didn't run the type check. bun x tsc --noEmit failed with "Cannot find type definition file for 'bun'", so it told me nothing about this change. The forge's check will run it on this push.

To try it: bun test test/thoughts-read.test.ts.

Approved

Test-only, one file, no change to src. I ran the three tests against src/core/thoughts.ts at main: 3 pass in 21 ms, with an in-memory database built from the real 0081 migration, so they are fast and do not flake. Each test would fail if the behaviour broke. Dropping author = ?1 makes bob see t1. Dropping the ORDER BY or the LIMIT breaks the id lists. Making since exclusive loses t3 at the exact boundary. Any trimming or normalising of the text breaks the byte-for-byte check, which covers markup, emoji, CRLF, tabs and surrounding spaces. That covers every box in #6715. There is no security surface: no input, output, write or secret. The preview answers 200 on /, and a test-only change has nothing else to show there. Approved.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs