Skip to content

fix: repair two pre-existing test failures - #21

Merged
kacheo merged 7 commits into
mainfrom
fix/preexisting-test-failures
Jun 7, 2026
Merged

kacheo merged 7 commits into
mainfrom
fix/preexisting-test-failures

Conversation

@kacheo

@kacheo kacheo commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • internal/configTestWrite_AtomicNoPanicOnError was failing in environments with elevated privileges (e.g. root) that bypass chmod 0500. Added a probe write after the chmod; if it succeeds, the test skips with a clear reason instead of failing.
  • internal/git — All initTempRepo-based tests (TestGetOriginSlug_*, TestScanCommits_*) were failing because the environment enforces mandatory GPG/SSH commit signing via a server that returns 400 for test repos. Fixed by setting commit.gpgsign = false locally on each temp repo — scoped to the test fixture only, no effect on real commits.

Neither fix changes production code or weakens what the tests verify. Both are environment adaptations only.

Test plan

  • go test ./internal/config/... — previously failing test now skips cleanly
  • go test ./internal/git/... — all 5 previously failing tests now pass
  • go test ./... — full suite green

https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z

claude added 5 commits June 7, 2026 22:00
Adds three new capabilities:
- `devlog tags [list]` — list all tags with per-day usage counts, sorted by
  frequency then alphabetically; supports --json for machine-readable output
- `devlog tags rename <old> <new>` — rename a tag across all day files with
  case-insensitive matching, preserving tag order and unaffected files
- `Store.AllDates()` — scans the journal dir for YYYY-MM-DD.md files,
  returns dates sorted oldest-first; reused by both ListTags and RenameTag

All functionality written TDD: tests were written first (22 new tests across
store and cmd packages) and the implementation written to make them pass.

https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
Updates CHANGELOG, README, user guide, and AGENT_INSTRUCTIONS to cover
the new tags list and tags rename subcommands — including terminal output
format, JSON schema, jq patterns, filtering workflow, and key behaviors
(case-insensitive match, per-day counts, atomic rename).

https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
Bug fix:
- RenameTag now deduplicates tags after rename, preventing [auth, oauth]
  + rename auth→oauth from producing [oauth, oauth]

Validation:
- RenameTag returns an error for empty old or new tag strings

New tests (store):
- TestRenameTag_NewTagAlreadyPresent — dedup when newTag already in entry
- TestRenameTag_NewTagAlreadyPresent_PreservesFirst — first-seen wins after dedup
- TestRenameTag_EmptyOldTag / TestRenameTag_EmptyNewTag — empty string guards
- TestAllDates_NonExistentDir — non-existent dir returns empty, not error

New tests (render):
- TestTagsTerminal_Empty / TestTagsTerminal_ShowsTagsAndCounts
- TestTagsJSON_EmptySlice / TestTagsJSON_Schema / TestTagsJSON_PreservesInputOrder

New tests (cmd):
- TestTagsRenameCmd_DeduplicatesWhenNewTagAlreadyPresent
- TestTagsRenameCmd_CaseInsensitive

https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
Tags must now match [a-z0-9_]+ at write time:
- devlog add --tag rejects uppercase, hyphens, spaces, and empty strings
- devlog tags rename rejects an invalid new tag name (old tag still
  matched case-insensitively to handle pre-existing legacy tags)

Implementation:
- store.ValidateTag() — single validation function with compiled regexp
- Wired into cmd/add.go (before Modify) and cmd/tags.go (before RenameTag)

Tests (TDD — written before implementation):
- TestValidateTag_Valid / TestValidateTag_Invalid (9 valid, 8 invalid cases)
- TestAddCmd_RejectsUppercaseTag / RejectsHyphenatedTag / RejectsEmptyTag
- TestTagsRenameCmd_RejectsInvalidNewTag

Docs updated: user-guide.md add section, tags rename section; AGENT_INSTRUCTIONS key behaviors.

https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
internal/config: TestWrite_AtomicNoPanicOnError
  The test chmod's a dir to 0500 then expects a write into it to fail.
  In environments running with elevated privileges the write succeeds,
  causing a false failure. Added a probe write after chmod; if it
  succeeds the test is skipped with a clear reason.

internal/git: TestGetOriginSlug_* / TestScanCommits_*
  initTempRepo runs `git commit` in a temp dir, but environments with a
  mandatory GPG/SSH signing hook hit a signing server that returns 400.
  Added `git config commit.gpgsign false` scoped to the temp repo so the
  commit is not subject to the global signing configuration.

https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
@kacheo kacheo changed the title feat: add devlog tags command for tag management fix: repair two pre-existing test failures Jun 7, 2026
claude and others added 2 commits June 7, 2026 22:26
The probe file's Close() error is intentionally ignored (it's a
write-permission probe in a test); use _ = f.Close() so errcheck
doesn't flag the unchecked return value.

https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kacheo
kacheo merged commit 879268e into main Jun 7, 2026
4 checks passed
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.

2 participants