nbascore: Switch to ESPN API, add tests, improve UX - #2151
Open
Seanstoppable wants to merge 3 commits into
Open
Conversation
- Add widget_test.go with table-driven tests using net/http/httptest - Test successful response parsing, empty games, non-200 status, invalid JSON, unreachable server, date offset formatting, score color formatting, active/inactive game highlighting, multiple games, request headers, settings defaults, and ConfigText - Extract nbaBaseURL to package-level var for test server injection - Fix nil pointer dereference bug in non-200 status code path (err was nil when checking response.StatusCode != 200)
The old data.nba.net API returns 400 and cdn.nba.com blocks non-browser
requests. Switch to ESPN's free public scoreboard API which requires no
authentication and works reliably.
- Use structured types instead of map[string]interface{} for JSON parsing
- Parse ESPN response format (events/competitions/competitors)
- Support date-based queries via ?dates= query parameter
- Use WTFUtil user agent string
- Add 10s HTTP client timeout
- Update tests to match new ESPN response structure
When the ESPN API returns no events (e.g. offseason), display 'No games scheduled' with the next game date if available from the API's day.date field.
Seanstoppable
force-pushed
the
seanstoppable-nbascore-test-coverage
branch
from
July 26, 2026 06:29
d1deffb to
7b2ef3b
Compare
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.
Summary
The nbascore module was broken because the data.nba.net API has been shut down (returns 400). This PR switches to ESPN free public scoreboard API, adds comprehensive unit tests, and improves the user experience during the offseason.
Changes
Switch to ESPN API
Add unit tests (0 to 74% coverage)
Improve offseason UX
Bug fix