-
Notifications
You must be signed in to change notification settings - Fork 6
chore: parameterize SubCommandTest with configLevel #239
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
chore: parameterize SubCommandTest with configLevel #239
Conversation
| func (suite *SubcommandTestSuite) TearDownTest() { | ||
| suite.Require().NoError(os.Unsetenv("ADBC_DRIVER_PATH")) | ||
| } |
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.
why remove this? If we're not going to remove this env var after each test, then we should move the os.Setenv to SetupSuite and add Unsetenv to TearDownSuite
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.
This got split out into platform specific TearDownTest methods (subcommand_unix_test.go, subcommand_windows_test.go)
| // Clean up the registry and filesystem after each test | ||
| _, user := os.LookupEnv("DBC_TEST_LEVEL_USER") | ||
| _, system := os.LookupEnv("DBC_TEST_LEVEL_SYSTEM") |
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.
what happens if both are set?
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.
If both are set, cleanup for both should run. Does that sound right?
config/config.go
Outdated
| func GetLocation(lvl ConfigLevel) string { | ||
| return lvl.configLocation() | ||
| } |
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.
why not just export lvl.configLocation instead?
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.
The last time you and I were looking at doing this, I think you mentioned not wanting to export lvl.configLocation so I exported a wrapper here instead. I'll remove the wrapper since I think it's fine just to export lvl.configLocation.
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.
Done in b7a3289. level.ConfigLocation is now exported.
| return fmt.Errorf("error removing manifest %s: %w", manifest, err) | ||
| } | ||
|
|
||
| // TODO: Remove this when the driver managers are fixed (>=1.8.1). |
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.
is there an issue on arrow-adbc to track this?
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.
This was fixed in apache/arrow-adbc@526dd93. We can file an issue here on dbc to do something about it.
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.
cmd/dbc/subcommand_test.go
Outdated
|
|
||
| func (suite *SubcommandTestSuite) SetupTest() { | ||
| suite.tempdir = suite.T().TempDir() | ||
| suite.Require().NoError(os.Setenv("ADBC_DRIVER_PATH", suite.tempdir)) |
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.
actually, we could save ourselves some trouble and just use suite.T().Setenv, let's do that
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.
Good call. I didn't know about that.
I realized we can make the change more comprehensively too so I did that in 643f102.
|
Thanks for the review @zeroshade. Ready for a re-review. |
zeroshade
left a comment
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.
LGTM! Thanks for this!
Extends the SubCommandTest test suite to be parameterized by configLevel so the subcommand tests can be run with
--levelset to user or system by running the test suite withDBC_TEST_LEVEL_USER=1orDBC_TEST_LEVEL_SYSTEM=1respectively.This is not enabled by default on developer machines but is enabled in CI. To opt in this behavior, tests need to be written to use
suite.configLevelto control their config level and tests can opt out either by not doing this or by doing this but adding appropriate Skips.To demo what we can do now, this PR also includes a fix for #215. We could have fixed the issue by testing in a tempdir but with the change in this PR we can actually test the bug that was reported. Doing this also uncovered some edge cases in the symlink behavior so this was time well spent.
Also fixes a minor undiscovered bug in removing manifest-only drivers: e69744f.
Supersedes #238
Closes #210
Closes #215