fix(test): enable template support in test command #358
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
Enable template support in
rpk connect testby explicitly passing the environment to the manager.Problem
Templates loaded via the
-tflag were not recognized during test execution (see benthos issue 287):Root Cause
RPK creates a cloned environment at startup via
service.NewEnvironment(). When templates are registered, they're added to this cloned environment, notbundle.GlobalEnvironment. The test command's manager was created without explicitly passing the environment, causing it to default tobundle.GlobalEnvironment(which doesn't have templates).Execution flow:
schema.Environment()(has built-in processors)schema.Environment()(now has templates too)schema.Environment()(parsing works ✓)bundle.GlobalEnvironment(no templates ✗)Solution
Pass the environment explicitly when creating the manager, matching the pattern used by the
runcommand (internal/cli/common/manager.go:107).Files changed:
internal/cli/test/processors_provider.go- Addmanager.OptSetEnvironment(p.env)internal/cli/test/processors_provider_test.go- Add integration testTesting
benthos test -t template.yaml test.yamlsucceedsNotes
bundle.GlobalEnvironmentdirectly)