Skip to content

test: tidy date helpers and rows.Err, rename the unlogged rule, add the binary comparison runner - #455

Merged
ryanlewis merged 2 commits into
mainfrom
test/tidy
Oct 10, 2026
Merged

ryanlewis merged 2 commits into
mainfrom
test/tidy

Conversation

@ryanlewis

Copy link
Copy Markdown
Owner

Small test-side tidy-ups. The only non-test change is a rename and its comment in internal/db.

  • rows.Err() in TestEditReadsTagListOnce: the loop over the schema rows now checks rows.Err() afterwards, so a failed read is not taken as an empty schema.

  • ThingsDate.AddDays in tests: each ThingsDateFromTime(t.AddDate(0, 0, n)) in a test is now ThingsDateFromTime(t).AddDays(n) (in add, edit, importcreate, when, membership, tasks and view_order tests). The dates are the same. The two uses in cmd/things/when.go are production code and are not changed here.

  • closedTodayUnlogged → closedUnlogged in internal/db/tasks.go: the rule covers every choice of the "Move completed items to Logbook" setting, including "manually" (logInterval 4), where a row is held whatever day it closed. So "today" in the name was wrong. The doc comment now says the two-condition rule is the "daily" one.

  • tools/compare/: the old-vs-new binary comparison runner used in the refactor: simplify code churned through 0.10.0 #442 review, now kept in the repo. run.sh runs two things binaries on fresh copies of a seeded test database (internal/db/dbtest/schema.sql plus seed.sql). open and osascript are replaced by shims that only log, so nothing reaches Things. It diffs stdout, stderr, the exit code, the shim log and the task statuses. The usage header at the top gives an example.

    $ OLD=/tmp/things-old NEW=/tmp/things-new SHIMAPPLY=1 tools/compare/run.sh c1 - complete TODO1
    SAME c1 (exit 0, shim 4)
    

/code-review

  • Applied to the runner: resolve OLD/NEW to absolute paths (under env -i a bare name was not found, and both runs failed the same way and reported SAME); build base.sqlite under a temporary name so a failed seed is not reused; exit 1 on DIFF; have the osascript shim stamp today's midnight rather than a fixed 2025 date, which counted as already logged. Also fixed a stale "AddDate" comment.
  • Not applied: escaping for a # in NAME/OUT in the sed path rewrite, and quoting a uuid in the shim's SQL (local dev tool, unusual input). Closing rows before the t.Fatalf calls inside the loop (it only matters once the test has already failed). Moving when.go:75,86 to AddDays (production code, outside this tests-only change).

@ryanlewis
ryanlewis merged commit 7d0eb31 into main Oct 10, 2026
8 checks passed
@ryanlewis
ryanlewis deleted the test/tidy branch October 10, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant