Skip to content

Replace devto-api-go with inline HTTP client and add tests - #2126

Merged
Seanstoppable merged 1 commit into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-inline-devto-api-and-add-tests
Jul 24, 2026
Merged

Seanstoppable merged 1 commit into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-inline-devto-api-and-add-tests

Conversation

@Seanstoppable

Copy link
Copy Markdown
Collaborator

Remove the archived github.com/VictorAvelar/devto-api-go dependency by inlining the DEV.to API calls using net/http + encoding/json.

Changes

  • modules/devto/client.go — New Client struct with injectable *http.Client and base URL. FetchArticles() makes a GET to the DEV.to public API with tag/username/state/per_page query params.
  • modules/devto/widget.go — Switched from the external library to the internal client. Extracted formatArticleRow() as a pure function. Made URL opener injectable for testability.
  • modules/devto/client_test.go — Tests fetch/parse, empty params, non-200 status, invalid JSON, connection errors.
  • modules/devto/widget_test.go — Tests Refresh (success, error, disabled, truncation), content rendering, openStory edge cases, formatting.
  • modules/devto/settings_test.go — Tests YAML config parsing with custom values and defaults.
  • go.mod/go.sum — Removed VictorAvelar/devto-api-go via go mod tidy.

Coverage

Before After
32.2% 98.7%

Remove the archived github.com/VictorAvelar/devto-api-go dependency by
implementing a small internal client (modules/devto/client.go) that calls
the DEV.to public API directly with net/http + encoding/json.

Changes:
- Add injectable Client with FetchArticles() using httptest-friendly design
- Extract formatArticleRow() as a testable pure function
- Make URL opener injectable for side-effect-free testing
- Add comprehensive test suite (98.7% coverage)
@Seanstoppable
Seanstoppable force-pushed the seanstoppable-inline-devto-api-and-add-tests branch from b6c1889 to 812dda5 Compare July 23, 2026 02:57
@Seanstoppable
Seanstoppable merged commit 3ca62bd into wtfutil:trunk Jul 24, 2026
4 checks passed
@Seanstoppable
Seanstoppable deleted the seanstoppable-inline-devto-api-and-add-tests branch July 24, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址