Skip to content

refactor: improve testability across app, ip, dns, notify, config#15

Open
orvice wants to merge 1 commit into
masterfrom
refactor/testability
Open

refactor: improve testability across app, ip, dns, notify, config#15
orvice wants to merge 1 commit into
masterfrom
refactor/testability

Conversation

@orvice

@orvice orvice commented May 17, 2026

Copy link
Copy Markdown
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>
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