memos/store/test
boojack 26f4b73cb9 feat(filter): standard CEL now variable, time accessors, set ops
Replace the custom now() function with an idiomatic `now` timestamp variable (host-injected, frozen once per compile) and retype created_ts/updated_ts/create_time to CEL timestamp. Filters now use standard timestamp/duration arithmetic, e.g. `created_ts >= now - duration("24h")` and `timestamp("2025-01-01T00:00:00Z")`.

Add standard CEL surface that compiles to SQL across SQLite/MySQL/Postgres: timestamp accessors (getFullYear/getMonth/getDate/getDayOfWeek/..., with 0-based month and weekday normalized), ext.Sets() (sets.contains/intersects/equivalent over tags), tags.exists_one(), size() on string fields, and division/modulo folding. A frozen clock is injectable for deterministic tests.

BREAKING CHANGE: now() is removed (use the `now` variable) and time fields are timestamps, so bare-epoch comparisons need timestamp(<epoch>). Existing saved shortcuts using the old syntax must be updated.
2026-06-22 22:42:44 +08:00
..
attachment_filter_test.go feat(filter): standard CEL now variable, time accessors, set ops 2026-06-22 22:42:44 +08:00
attachment_test.go fix: delete user cleanup (#5981) 2026-05-25 22:10:29 +08:00
containers.go test: stabilize backend tests in CI 2026-05-08 22:24:54 +08:00
database_size_test.go feat(stats): admin instance resource statistics 2026-05-01 23:15:56 +08:00
filter_helpers_test.go feat(filter): standard CEL now variable, time accessors, set ops 2026-06-22 22:42:44 +08:00
idp_test.go feat: replace auto-increment ID with UID for identity provider resource names (#5687) 2026-03-05 21:01:22 +08:00
inbox_test.go refactor(inbox): store memo comment payloads without activity records (#5741) 2026-03-19 19:33:25 +08:00
instance_setting_test.go feat(ai): add BYOK audio transcription (#5832) 2026-04-13 22:09:24 +08:00
main_test.go fix: resolve flaky migration tests and add stable upgrade test (#5514) 2026-01-20 19:25:00 +08:00
memo_filter_functions_test.go feat(filter): standard CEL now variable, time accessors, set ops 2026-06-22 22:42:44 +08:00
memo_filter_test.go feat(filter): standard CEL now variable, time accessors, set ops 2026-06-22 22:42:44 +08:00
memo_relation_test.go perf: batch load memo relations when listing memos (#5692) 2026-03-07 11:19:19 +08:00
memo_test.go test(store): add tests for CreateMemo with custom timestamps 2026-03-01 19:08:27 +08:00
migrator_test.go feat(settings): move tag metadata to user settings (#6017) 2026-06-07 23:58:00 +08:00
migrator_upgrade_test.go test: stabilize backend tests in CI 2026-05-08 22:24:54 +08:00
reaction_test.go
README.md
store.go refactor: migrate HOST roles to ADMIN 2026-01-20 23:38:30 +08:00
user_delete_test.go fix: delete user cleanup (#5981) 2026-05-25 22:10:29 +08:00
user_identity_test.go feat(auth): add SSO user identity linkage (#5883) 2026-04-23 08:51:45 +08:00
user_setting_test.go feat(instance): add canonical tag metadata setting (#5736) 2026-03-19 08:54:43 +08:00
user_test.go fix: delete user cleanup (#5981) 2026-05-25 22:10:29 +08:00

Store tests

How to test store with MySQL?

  1. Create a database in your MySQL server.
  2. Run the following command with two environment variables set:
DRIVER=mysql DSN=root@/memos_test go test -v ./test/store/...
  • DRIVER should be set to mysql.
  • DSN should be set to the DSN of your MySQL server.