Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added support for types assignable to special step argument types #28

Merged
merged 2 commits into from
Jan 17, 2024

Conversation

bondsb
Copy link
Contributor

@bondsb bondsb commented Jan 11, 2024

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 the Name() 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 in gocuke.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.

Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay but can we add some small test case?

@bondsb
Copy link
Contributor Author

bondsb commented Jan 16, 2024

Added a copy of the simple test that fails with the previous code and passes with the change.

@aaronc aaronc merged commit d7d6b11 into regen-network:main Jan 17, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants