Repository navigation
Test: add HA bridge nil-safety and diagnostic method tests - #48
Conversation
The HA bridge had zero test coverage. Add tests for all public diagnostic methods (IsConnected, BrokerAddr, LastPublishMs, SensorsAnnounced) on nil, zero-value, and configured Bridge instances. No MQTT broker needed — tests exercise the code paths the API layer relies on without network I/O. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ab296e9bbb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| b.mu.Lock() | ||
| b.sensorsAnnounced = expected | ||
| b.mu.Unlock() |
There was a problem hiding this comment.
Invoke production path for sensor-count formula test
This test never exercises publishDiscovery; it computes expected and then writes b.sensorsAnnounced directly, so it can pass even if the production formula or assignment in publishDiscovery regresses. In practice, any future bug where discovery publishes a different number of sensors (or forgets to update the field) would not be caught, despite the test name/comment claiming it validates that behavior.
Useful? React with 👍 / 👎.
|
🎉 This PR is included in version 2.0.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
…overs (#1456) * refactor(state,mpc,api): remove dead storage, planner and backup leftovers - #49 Keep on a driver draft now takes the driver update lock and removes the record before the saved original, so an expiry already in flight finishes first and Keep answers 409 instead of "kept" for a reverted draft. - #20 History maintenance runs only the plain SQLite stages. Remove the Parquet archive pipeline (rolloff, aggregate/sample archive, legacy compaction, cold/diagnostic Parquet pruning, Store.Prune) and the unused retentionDays closure of rolloffLoop; keep the Parquet readers. - #40 Drop the hot-history alias (s.hot, hotPath, hotWriteMu), dead hot-only branches and readers, forceRotate, heldBytes, RotateHistory and the test-only historyWriter.maintainHistory. - #41 Remove the always-empty ImportedHistoryFiles filter, the unused coldDir parameter of legacyHistoryIdle and the test-only backup.Restore; round-trip tests now use RestoreContents. - #29 Remove the recourse/multistage challenger, unix and auto transports, transport Health and the stateful shadow evaluator. The worker request keeps the same solver settings as constants; the Energyplan process transport and Core DP shadow are unchanged. - #47 Remove the always-zero PV nameplate and load caps (Service fields, Plan.pv_nameplate_w/load_max_w, forecast ACLimitW/ClampForecasts and their web chart caps), the load rain-check and test-only wrappers. A single sanitiser still maps NaN or negative load to 0 W. - #48 Handshake errors now say the bundled Energyplan worker does not match Core and to run `ftw update` or reinstall. Drop PYTHONPATH and fix stale Update Center, CVXPY, Python shadow and scenario comments. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7 * test(mpc): the native contract test no longer expects a scenario model The shared PV scenarios in buildRequest were reachable only by calling ExternalOptimizer directly with a risk margin; production runs through EnergyplanOptimizer, which applies the margin to the slots and zeroes it before the request. Removing that dead block left the native contract test asking for three scenarios. It now checks that a margin never builds a scenario model. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7 --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
go/internal/ha/bridge_test.gowith 6 test functions (7 sub-tests) covering all public diagnostic methods on the HA bridge*Bridge), zero-value safety (&Bridge{}),BrokerAddrformatting (IP + hostname),SensorsAnnouncedpre-discovery state and formula, andLastPublishMsmutex round-tripTest plan
go test -v ./internal/ha/passes (7/7)go test ./...passes (pre-existingconfigreloadfailure is unrelated)🤖 Generated with Claude Code