mirror of
https://github.com/therealpaulgg/ssh-sync.git
synced 2026-04-26 16:05:51 +03:00
[GH-ISSUE #80] Refactor retrieval package to use dependency injection instead of package-level function vars #27
Labels
No labels
ai-generated
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ssh-sync#27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @therealpaulgg on GitHub (Feb 24, 2026).
Original GitHub issue: https://github.com/therealpaulgg/ssh-sync/issues/80
Background
The
pkg/retrievalpackage currently uses package-level function variables to allowGetTokenandRetrieveMasterKeyto be swapped out in tests:This was introduced to make the tests CI-compatible (previously they read directly from
~/.ssh-sync/and required a configured environment). It works, but has drawbacks:t.Cleanupdiscipline to avoid test pollutionProposed solution
Introduce a
Clientstruct inpkg/retrievalthat holds the dependencies as fields:Tests construct a
Clientdirectly with stub functions — no globals, no cleanup:Scope
pkg/retrievalfunctions to methods onClientpkg/actionsto construct and use aClientdeps.goand the package-level varsClientinline — no mocking helpers needed