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

[dev2][conf] Improvements #11575

Merged
merged 8 commits into from Jul 8, 2022

Conversation

franramirez688
Copy link
Contributor

Changelog: Bugfix: Fixed the wrong behavior about writing -c core.xxx=value via CLI.
Changelog: Feature: Raising an exception if the internal configuration is used and it does not exist in the configuration list. It only affects tools* and core* ones.
Changelog: Feature: Brought conan config list command back.
Docs: https://github.com/conan-io/docs/pull/XXXX
Closes: #11346

@franramirez688 franramirez688 added this to the 2.0.0-beta2 milestone Jul 5, 2022
@franramirez688 franramirez688 changed the title Feature/conf improvements [dev2][conf] Improvements Jul 5, 2022
@franramirez688 franramirez688 linked an issue Jul 5, 2022 that may be closed by this pull request
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

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

Looking good!

conans/model/conf.py Show resolved Hide resolved
conans/model/conf.py Show resolved Hide resolved
@franramirez688 franramirez688 marked this pull request as ready for review July 6, 2022 14:04
conans/test/unittests/cli/common_test.py Outdated Show resolved Hide resolved
"core.doesnotexist:never",
"core:doesnotexist"
])
def test_core_confs_not_allowed_via_cli(conan_api, argparse_args, conf_name):
Copy link
Member

Choose a reason for hiding this comment

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

This test reads complex, too many mocks, etc. If it is a unit test of profile loader, why unittesting the get_profiles_from_args which is a cli helper, instead of testing the profile loader (that can be directly called by the Python API ProfileAPI without calling that cli helper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I wanted to test the function that is used by several commands at the same time. If I test the ProfileLoader I could not ensure that the commands are getting that function so I thought it was better covered so. That was the reason.
Talking about mocks, I don't think a mock for argparse is too much but I can change the test and call only the ProfileLoader function if you think is good enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just added another unittest for ProfileLoader. If you want, I can get rid of this one.

Copy link
Member

Choose a reason for hiding this comment

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

No need to remove it now it is done, but in general, the definition of "unittest" is testing the unit that is getting the code changes, in this case the "ProfileLoader". It is not about ensuring that certain commands behave some way, that is an "integration" test. The test that you added is much simpler (less mocking), and it guarantees that no matter what changes in the command layer, new commands, refactors, etc, profiles will keep raising if bad conf is defined. For example the ProfileAPI sub-api was not being covered by the first test, but now it is. Thanks!

"core.doesnotexist:never",
"core:doesnotexist"
])
def test_core_confs_not_allowed_via_cli(conan_api, argparse_args, conf_name):
Copy link
Member

Choose a reason for hiding this comment

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

No need to remove it now it is done, but in general, the definition of "unittest" is testing the unit that is getting the code changes, in this case the "ProfileLoader". It is not about ensuring that certain commands behave some way, that is an "integration" test. The test that you added is much simpler (less mocking), and it guarantees that no matter what changes in the command layer, new commands, refactors, etc, profiles will keep raising if bad conf is defined. For example the ProfileAPI sub-api was not being covered by the first test, but now it is. Thanks!

@czoido czoido merged commit ac88a3a into conan-io:develop2 Jul 8, 2022
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.

[dev2][feature] conf review and improvements
3 participants