-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Improve Unit Test Experience for Functionality using Azure CLI Configuration #25796
Comments
@wangzelin007 for awareness |
@wangzelin007 Thanks for the update! While the I suppose this functionality is more in the |
Sorry but I didn't really get the questions here. The behavior of
Is this a question or conditional? The current behavior of
Without specifying
It can't simply warns since it doesn't know which value to use. |
After this PR is merged, each test can use random config dir. |
@jiasli Thanks for the insights! This behavior is difficult to catch in tests, which led to the issue here, because the config file is re-used across tests, and in our case, we never got the Since this is the expected behavior and I assume authors either must ensure a fallback value is present or handle the Since this was the first time I was using this API, it wasn't obvious to me that this line could raise an exception and testing it missed as well since the config file was being shared. @bebound Yes. I think that should help. So, will we be able to change the config dir for each test as part of the Also, considering there is a performance impact, wouldn't it make sense to make the config file in-memory and have an API to clear it before each test to speed things up? |
IMHO, most test only read config. Modifying specific tests is more efficient than using dedicate config directory for each test. We need to add I don't know if there is an easy and cross-platform way to create in-memory folders. |
Is your feature request related to a problem? Please describe.
When writing unit test for functionality that leverages Azure CLI Configuration, the config is persisted across tests leading to misleading results.
Most recently, new functionality in the
az bicep
sub-command leveraged Azure CLI Configuration but a bug slipped through the tests due to the config value not being reset with each test, causing numerous build pipeline failures for customers.Describe the solution you'd like
Better unit testing experience for such functionality. Based on this last experience, here are some thoughts I had:
DummyCLI
No Section
cli_ctx.config.get()
without default value. Warning at the minimum.The text was updated successfully, but these errors were encountered: