Skip to content

Tests: fixture dates from the clock, and assertions that need the command to have acted - #112

Merged
muellerei merged 2 commits into
mainfrom
fix/test-fixture-dates
Oct 3, 2026
Merged

muellerei merged 2 commits into
mainfrom
fix/test-fixture-dates

Conversation

@muellerei

Copy link
Copy Markdown
Owner

Two fixes to the suite, no change to any command.

Date-dependent fixtures

Ten tests fail from 2026-10-11 and one more from 2027-01-01. Their fixtures hold a fixed journal day (2026-09-10, August 2026) while the commands under test filter against "last 30 days" or "this year"; once the day leaves the window the command sees an empty journal and the assertions fail. journal_day() in tests/conftest.py now derives the day from the clock.

Two tests also looped over the entries of a result and passed over an empty one (get-journal-summary --no-content, silently from 2027; get-journal-range --heading, on an empty journal at any date). Both now assert the list is not empty.

Tests that cannot fail

Sixteen tests pass whether or not the command did anything: they assert exit code 0 and, at most, that something was not written. One searched stderr for "dead" where the message reads "no longer exists", so it could not fail at all. Each now asserts something that exists only if the command acted.

Found by making CliRunner.invoke a no-op (exit 0, no output): 135 tests still passed, and for 16 of them no twin test proved that the command acted. test_survives_an_empty_graph now requires exit 0 and JSON where it allowed SystemExit.

Checked

  • 3265 tests, ruff check ., on every commit.
  • Faked clock on 15 dates through 2028 (month ends, year change, leap day) at 00:00 and 23:59: all pass. With the old fixtures the same sweep fails on 2026-10-11 (10 tests) and 2027-01-01.
  • With invoke a no-op, fourteen of the sixteen tests fail now. The other two were mutated on their own: forcing --resolve-refs on makes the new dead-ref assertion fail where the old one passed; get-todos --from 2099, which drops every task, fails the new get-todos assertion.

Two commits, one per fix; each stands on its own and has its changelog entry.

Ten tests broke on 2026-10-11 and one more on 2027-01-01. Their fixtures
held fixed journal days (2026-09-10, 2026-08-xx) while the commands under
test filter against "last 30 days" / "this year". Once the fixture left the
window, the command saw an empty journal and the assertions failed.

journal_day() in conftest gives a journalDay relative to today. The
analyze-journal-patterns and mood tests use it, and the get-journal-summary
tests get pages inside the current year.

Two tests in test_journal_bounded_output looped over entries and passed
over an empty list: the no-content test (silently, from 2027) and the
heading test (with an empty journal at any date). Both now assert the list
is not empty; an empty journal makes each of them fail.

Checked with a faked clock on 15 dates through 2028 (month ends, year
change, leap day) at 00:00 and 23:59: all 3265 tests pass. With the
fixtures reverted, the same sweep fails on 2026-10-11 (10 tests) and
2027-01-01.
Sixteen tests passed whether or not the command did anything. Most asserted
exit code 0 and, at most, that something was not written; one searched
stderr for "dead" where the message reads "no longer exists", so it could
not fail at all. A command that silently returned early passed them.

Each now asserts something that exists only if the command acted: the
written block, the rendered page, the dry-run notice, the query sent, the
JSON payload. test_survives_an_empty_graph now requires exit 0 and JSON on
an empty graph instead of allowing SystemExit.

Found by turning CliRunner.invoke into a no-op (exit 0, no output) and
listing the tests that still passed, then reading each against a twin that
proves the effect. 135 passed under the no-op; 16 had no such twin.

Checked: with invoke a no-op, fourteen of them now fail. The other two
cannot show it that way and were mutated separately: forcing resolve_refs on in
get-page makes the new dead-ref assertion fail where the old one passed,
and --from 2099, which drops every task, makes the get-todos assertion
fail.
@muellerei
muellerei merged commit 8e4bf80 into main Oct 3, 2026
6 checks passed
@muellerei
muellerei deleted the fix/test-fixture-dates branch October 3, 2026 03:04
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