refactor: improve testability across app, ip, dns, notify, config#15
Open
orvice wants to merge 1 commit into
Open
refactor: improve testability across app, ip, dns, notify, config#15orvice wants to merge 1 commit into
orvice wants to merge 1 commit into
Conversation
orvice
commented
May 17, 2026
Owner
- App.Run now uses a Ticker, returns error instead of os.Exit, and exposes WithInterval for tests; updateIP split into findRecord / appendRecord / updateRecord helpers.
- IfconfigCo accepts an injectable HTTP client and URL via the new NewIfconfigCo constructor; production path unchanged.
- dns.New returns (LibDNS, error) so unknown providers fail loudly; empty value still defaults to Cloudflare.
- notify drops the package-level notifiers slice / Init / AddNotifier / Notify globals. TelegramNotifier now depends on a minimal tgSender interface; new MultiNotifier replaces the global fan-out.
- config.New uses an independent viper.New() instance with explicit BindEnv calls so tests can run without sharing global viper state.
- main.go propagates Run errors and exits non-zero on failure.
- Added unit tests with hand-written fakes for app, ip (httptest), dns provider selection, and notify (fake bot + MultiNotifier).
- App.Run now uses a Ticker, returns error instead of os.Exit, and exposes WithInterval for tests; updateIP split into findRecord / appendRecord / updateRecord helpers. - IfconfigCo accepts an injectable HTTP client and URL via the new NewIfconfigCo constructor; production path unchanged. - dns.New returns (LibDNS, error) so unknown providers fail loudly; empty value still defaults to Cloudflare. - notify drops the package-level notifiers slice / Init / AddNotifier / Notify globals. TelegramNotifier now depends on a minimal tgSender interface; new MultiNotifier replaces the global fan-out. - config.New uses an independent viper.New() instance with explicit BindEnv calls so tests can run without sharing global viper state. - main.go propagates Run errors and exits non-zero on failure. - Added unit tests with hand-written fakes for app, ip (httptest), dns provider selection, and notify (fake bot + MultiNotifier). Co-Authored-By: Craft Agent <agents-noreply@craft.do> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.