You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request updates the logic in the testing/generate.go file to improve how the example implementation package name is determined when generating test suites. Instead of deriving the package name using string manipulation, the code now extracts it directly from the file header metadata, making the process more robust and accurate.
Improvements to package name determination:
Changed the method for determining the example implementation package name in GenerateExample to extract it from the file header's Pkg field, rather than constructing it from the service name using string manipulation.
Code cleanup:
Removed the unnecessary import of the strings package from testing/generate.go.
Nice, I like the direction here. Reading the package from generated metadata is a lot nicer than reconstructing it from the service name.
One case I think we still need to handle: files only has the files generated during this goa example run. If the example service implementation already exists, Goa skips emitting <service>.go, so this loop can end up grabbing the package from some other generated file, like main or interceptors. Then the root suite file would be generated with the wrong package on reruns or when adding the testing plugin to an existing example project.
Could we either keep using the same API package derivation Goa uses for the top-level service implementation, or make this lookup target that specific top-level service file and handle the already-exists case explicitly? A small test for the existing-service-file/rerun case would be great too.
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
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.
This pull request updates the logic in the
testing/generate.gofile to improve how the example implementation package name is determined when generating test suites. Instead of deriving the package name using string manipulation, the code now extracts it directly from the file header metadata, making the process more robust and accurate.Improvements to package name determination:
GenerateExampleto extract it from the file header'sPkgfield, rather than constructing it from the service name using string manipulation.Code cleanup:
stringspackage fromtesting/generate.go.