-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add ability to create a clio.Application that runs test assertions instead of cmd.RunE #37
Conversation
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Will Murphy <[email protected]>
Signed-off-by: Will Murphy <[email protected]>
Signed-off-by: Will Murphy <[email protected]>
The initializers may not be safe to run twice. Signed-off-by: Will Murphy <[email protected]>
Signed-off-by: Will Murphy <[email protected]>
There are testutils packages everywhere. Rename clio's testutils package to cliotestutils so that it's more obvious what's being imported. Signed-off-by: Will Murphy <[email protected]>
This will be more readable when called as cliotestutils.NewApplication. Signed-off-by: Will Murphy <[email protected]>
// env vars, and config files. Useful for testing that expected configuration options are wired up. | ||
// Note that initializers will be cleared from the clio setup config, since the initialization may happen | ||
// more than once and affect global state. For necessary global state, a workaround is to set it in a TestingMain. | ||
func NewApplication(t *testing.T, cfg *clio.SetupConfig, assertions ...AssertionFunc) clio.Application { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the composition approach here - it might get tough to debug this, since the assertions can happen so far away from the thing they are asserting against, but I think that's a second order concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a first pass, this looks good for what it is supposed to do; we can always expand on it later if need be
Pull request adding a method to write unit tests that assert on the result of setting up the config in fangs/clio.