Skip to content

test(autostart): keep the Linux tests away from an agent installed on the machine - #12

Merged
lorenzocorallo merged 1 commit into
mainfrom
fix/autostart-test-hermetic
Oct 17, 2026
Merged

lorenzocorallo merged 1 commit into
mainfrom
fix/autostart-test-hermetic

Conversation

@lorenzocorallo

Copy link
Copy Markdown
Member

TestInstalledParsesEntries fails on any Linux machine where the agent is installed from the package:

linux_test.go:18: installed with no entries

The test points XDG_CONFIG_HOME at a temporary directory, but Installed() also reads the package's unit (/usr/lib/systemd/user/polinetwork-esign.service) and its global enablement (/etc/systemd/user/default.target.wants/…). With the package installed, it finds them and reports the agent as installed before the test has written anything. The code is right; the test was not isolated from the machine.

  • isolate(t) points the user config directory and the package unit paths (systemUnits, globalEnabled) at temporary directories, and restores them after the test.
  • New TestInstalledPackageUnit: the package unit counts as installed only once enabled for every user.

Test-only change. go test ./... passes on a machine with the agent installed.

… the machine

TestInstalledParsesEntries redirected XDG_CONFIG_HOME but still read the package's unit in /usr/lib/systemd/user and its global enablement in /etc/systemd/user, so on a machine with the agent installed Installed() found it and the test failed. The tests now point those paths at a temporary directory too, and a new test covers the package unit, which counts only once enabled for every user.
@coderabbitai

coderabbitai Bot commented Oct 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 29 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 751cfa3a-a74a-4324-9d1e-bee6c4cce524
📥 Commits

Reviewing files that changed from the base of the PR and between 9bfb731 and e5aa1a0.

📒 Files selected for processing: 1
  • internal/autostart/linux_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lorenzocorallo
lorenzocorallo merged commit 7bc5fa7 into main Oct 17, 2026
15 checks passed
@lorenzocorallo
lorenzocorallo deleted the fix/autostart-test-hermetic branch October 17, 2026 17:51
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