feat: added support for types assignable to special step argument types #28
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 update adds support for injecting special step arguments whose types are assignable to the 4 supported types (in contrast to supporting only arguments whose types are precisely those 4).
Background use case: Terratest
I wanted to use gocuke with Terratest. Injecting a
gocuke.TestingT
into my suite didn't provide theName()
method required by Terratest:./gocuke_test.go:51:25: cannot use s (variable of type *suite) as "github.com/gruntwork-io/terratest/modules/testing".TestingT value in argument to terraform.InitAndApply: *suite does not implement "github.com/gruntwork-io/terratest/modules/testing".TestingT (missing method Name)
I added
Name()
to a custom interface that includes all the methods ingocuke.TestingT
. But this was not injected via the special step arguments.My solution was to modify this behavior in
runner.go
to inject based on assignability instead of equality.