Download this file
| 1 | package memoriatest |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | |
| 6 | "amadan.net/oficina/suite" |
| 7 | |
| 8 | "amadan.net/oficina/memoria/internal/memoria" |
| 9 | ) |
| 10 | |
| 11 | // testAsker is the person every store-level test searches as. |
| 12 | // |
| 13 | // §4.1's typed subject in lone shape: a lowercased address, with the kind |
| 14 | // on the value so a receiver keyed on person refs answers UNKNOWN for the |
| 15 | // whole call rather than guessing. |
| 16 | var testAsker = suite.Subject{Kind: suite.SubjectAddress, Value: "reader@example.com"} |
| 17 | |
| 18 | // searchAsReader runs a search as an ordinary signed-in reader and returns |
| 19 | // the passages that survived §4.1's ruling. |
| 20 | // |
| 21 | // **It is not a way around the ruling and must never become one.** It |
| 22 | // calls Store.Search like everything else does; all it supplies is the |
| 23 | // asker the test would otherwise have to spell out at thirty call sites, |
| 24 | // and all it drops is the notices, which these tests are not about. A |
| 25 | // helper that reached past Search to the raw hits would be the seam |
| 26 | // AGENTS.md warns about — the guard that exists only in a comment. |
| 27 | func searchAsReader(s *memoria.Store, ctx context.Context, q string, n int) ([]memoria.Result, error) { |
| 28 | p, err := s.Search(ctx, testAsker, q, n) |
| 29 | return p.Results, err |
| 30 | } |
| 31 | |