Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various incremental improvements #73

Closed
wants to merge 7 commits into from
Closed

Conversation

jnd-au
Copy link
Contributor

@jnd-au jnd-au commented Oct 28, 2024

This PR addresses multiple issues:

  1. Minor code style improvements.
  2. Unit-test coverage raised from 84.5% to 93.2% (including main.go coverage raised from 31.6% to 76.5%).
  3. Fix Exit code for empty -list search #70
  4. Fix Cannot show UNIX epoch with -when 0 #71
  5. Fix main.go lacks sufficient unit test coverage #72

This includes feature-support for date-times like tz -when 2006-01-02T15:04:05-07:00.

Internally, main.go tests are supported through the new files os_wrapper.go and os_wrapper_test.go which provide our own os:

  1. Capture & test exit codes without exiting.
  2. Capture & test stderr messages instead of printing to console.
  3. Test flag CLI argument parsing.
  4. Test error-handling code paths.
  5. Clean env vars for each test.
  6. Simulate home dir scenarios.
  7. Virtual test file I/O in-memory

The residual warts are:

  1. Need to add return after os.Exit to support unit testing (in unit-test mode, our os.Exit records the exit code without exiting, so the function needs to return instead).
  2. Need to access os.Stdout() as an interface function instead of a package field.

@oz
Copy link
Owner

oz commented Oct 28, 2024

I'm grateful for the contributions, but please don't make one PR for shopping-list issues that you also created yourself.

@oz oz closed this Oct 28, 2024
@jnd-au
Copy link
Contributor Author

jnd-au commented Oct 28, 2024

FYI all the commits are interrelated with providing the missing test coverage, which is why I bundled these changes after the other PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants