Skip to content

Unit tests do not use real $HOME #261

Merged
carole-lavillonniere merged 1 commit into
mainfrom
feed-67-tests-perhaps-shouldnt-assume-home-always-exists
May 26, 2026
Merged

Unit tests do not use real $HOME #261
carole-lavillonniere merged 1 commit into
mainfrom
feed-67-tests-perhaps-shouldnt-assume-home-always-exists

Conversation

@carole-lavillonniere
Copy link
Copy Markdown
Collaborator

@carole-lavillonniere carole-lavillonniere commented May 26, 2026

Motivation

Under Nix's sandboxed build, $HOME is set to /homeless-shelter (a deliberately non-existent placeholder), so TestParseDestination fails because it calls os.UserHomeDir() which does not exist.

Changes

  • Add a home parameter to snapshot.ParseDestination
  • Switch TestParseDestination to use t.TempDir() as home so it is hermetic
  • Add TestParseDestinationTildeWithoutHome to test the Nix scenario

Tests

  • make test — all 520 unit tests pass.
  • Verified the Nix-sandbox scenario locally: HOME=/homeless-shelter go test ./internal/snapshot/... passes (and failed before this change).

Closes FEED-67

@carole-lavillonniere carole-lavillonniere changed the title Make snapshot tests work without a real $HOME Unit tests work without a real $HOME May 26, 2026
@carole-lavillonniere carole-lavillonniere changed the title Unit tests work without a real $HOME Unit tests work without a real $HOME dir May 26, 2026
@carole-lavillonniere carole-lavillonniere changed the title Unit tests work without a real $HOME dir Unit tests do not use real $HOME May 26, 2026
@carole-lavillonniere carole-lavillonniere marked this pull request as ready for review May 26, 2026 09:34
@carole-lavillonniere carole-lavillonniere merged commit 160fdcb into main May 26, 2026
12 of 13 checks passed
@carole-lavillonniere carole-lavillonniere deleted the feed-67-tests-perhaps-shouldnt-assume-home-always-exists branch May 26, 2026 12:02
@purcell
Copy link
Copy Markdown

purcell commented May 27, 2026

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants