Skip to content

Test Coverage, CLAUDE.md, and README Footer#39

Merged
cjimti merged 3 commits intomasterfrom
testing/increse_coverage
Feb 6, 2026
Merged

Test Coverage, CLAUDE.md, and README Footer#39
cjimti merged 3 commits intomasterfrom
testing/increse_coverage

Conversation

@cjimti
Copy link
Member

@cjimti cjimti commented Feb 6, 2026

Test Coverage Improvements

Before

  • Total: 90.2%
  • Core library (txeh.go): 96.8%
  • CLI cmd package: 44.7%

After

  • Total: 92.4%
  • Core library (txeh.go): 96.8%
  • CLI cmd package: 81.6%

What was added (txeh/cmd/root_test.go)

DryRun path tests for commands that were only tested in save mode:

  • TestRemoveIPs_DryRun
  • TestRemoveIPRanges_DryRun
  • TestRemoveByComment_DryRun

VersionFromBuild tests:

  • TestVersionFromBuild_GoreleaserVersion - covers the goreleaser-set version path
  • TestVersionFromBuild_Default - covers the debug.ReadBuildInfo() path

initEtcHosts tests:

  • TestInitEtcHosts_DefaultPath - covers NewHostsDefault() path (empty paths + zero max)
  • TestInitEtcHosts_EmptyPathsNonZeroMax - covers NewHosts path with custom max

Cobra Args validation tests for all commands:

  • TestAddCmd_Args_Valid, _TooFew, _InvalidIP, _InvalidHostname
  • TestRemoveHostCmd_Args_Valid, _Empty, _InvalidHostname
  • TestRemoveIPCmd_Args_Valid, _Empty, _InvalidIP
  • TestRemoveCidrCmd_Args_Valid, _Empty, _InvalidCIDR
  • TestRemoveCommentCmd_Args_Valid, _Empty
  • TestListByHostsCmd_Args_Valid, _Empty, _InvalidHostname
  • TestListByIPCmd_Args_Valid, _Empty, _InvalidIP
  • TestListByCidrCmd_Args_Valid, _Empty, _InvalidCIDR
  • TestListByCommentCmd_Args_Valid, _Empty
  • TestShowCmd_Args

Cobra Run function tests for all commands:

  • TestAddCmd_Run_Basic, _WithComment, _NotQuiet, _NotQuiet_WithComment
  • TestRemoveHostCmd_Run, TestRemoveIPCmd_Run, TestRemoveCidrCmd_Run, TestRemoveCommentCmd_Run
  • TestListByHostsCmd_Run, TestListByIPCmd_Run, TestListByCidrCmd_Run, TestListByCommentCmd_Run
  • TestShowCmd_Run, TestVersionCmd_Run

Remaining uncovered code

  • os.Exit(1) error paths in cmd functions (require process forking to test)
  • Execute() function (cobra wrapper, 0%)
  • main() in txeh/txeh.go (0%, standard for Go CLIs)

CLAUDE.md Updates

  • Fixed verify-full description (was incorrectly described as "Run all tests including integration")
  • Added inline descriptions to Quick Reference make targets
  • Added missing make targets: lint-fix, test-integration, test-e2e, dead-code, check, mutate
  • Updated goreleaser command from v1 syntax to v2 (goreleaser release --snapshot --clean)
  • Added GNUmakefile, test/integration/, test/e2e/ to File Naming Conventions table

README.md Footer

Added attribution footer before the link reference definition.

Enhance documentation to include detailed descriptions for existing and new Makefile targets, updated build and testing commands, and clarified directory structure for integration and E2E tests.
Add attribution to Craig Johnston and sponsorship acknowledgment for Deasil Works, Inc. at the end of the README.
Extend test coverage with dry-run tests for `RemoveIPs`, `RemoveCIDRs`, and `RemoveByComment`. Add validation tests for CLI commands, including `add`, `remove`, `list`, and `show` commands, and run function tests to ensure correct command behavior.
@cjimti cjimti self-assigned this Feb 6, 2026
@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.90%. Comparing base (bedfe2c) to head (cfa2c72).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #39       +/-   ##
===========================================
+ Coverage   72.48%   88.90%   +16.42%     
===========================================
  Files          15       15               
  Lines         676      676               
===========================================
+ Hits          490      601      +111     
+ Misses        165       60      -105     
+ Partials       21       15        -6     

see 12 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cjimti cjimti merged commit d2f988f into master Feb 6, 2026
9 checks passed
@cjimti cjimti deleted the testing/increse_coverage branch February 6, 2026 02:17
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