Fix websocket import in mains plugin and ArrayOf type assertion in testing plugin #235
+108
−43
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
This PR contains two bug fixes:
1. mains: Fix websocket import detection for server mains
The mains plugin was using
httpcodegen.NeedDialer()to detect websocket usage, but that function is designed for client dialers, not servers. This caused thegithub.com/gorilla/websocketimport to be missing whenwebsocket.Upgraderwas emitted in the generated main.Fix: Use
httpWebSocketByService()to detect streaming endpoints that require websocket support, matching the same detection used forHasAnyWebSocketin the template.2. testing: Fix type assertion for ArrayOf results in ScenarioRunner (#234)
The testing plugin was generating invalid Go for array results in
ScenarioRunner.callValidator, producing code like:instead of the correct:
This was caused by hardcoding the assertion shape as
result.(*{{Pkg}}.{{Result}}), which breaks for composite types likeArrayOf(...).Fix: Use Goa's
GoFullTypeRefto compute the properly qualified type reference (handling*,[],map[...], etc.) and store it in a newResultTypeReffield onscenarioMethodData.Testing
go test ./...)TestGenerateScenarios_ArrayResultTypeAssertionto ensure the ArrayOf type assertion fix never regressesTestWebSocketMainIncludesUpgraderto check the correct section for the websocket importFixes #234