Repository navigation
Tests: fixture dates from the clock, and assertions that need the command to have acted - #112
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()intests/conftest.pynow 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.invokea 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_graphnow requires exit 0 and JSON where it allowedSystemExit.Checked
ruff check ., on every commit.invokea no-op, fourteen of the sixteen tests fail now. The other two were mutated on their own: forcing--resolve-refson makes the new dead-ref assertion fail where the old one passed;get-todos --from 2099, which drops every task, fails the newget-todosassertion.Two commits, one per fix; each stands on its own and has its changelog entry.