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

Test coverage for auth configuration #3285

Merged
merged 2 commits into from
May 18, 2024
Merged

Conversation

thomas11
Copy link
Contributor

This is a core part of the provider that lacked coverage. Also includes the new #3281.

Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@mikhailshilkov
Copy link
Member

It looks like some of the tests are failing

@thomas11
Copy link
Contributor Author

thomas11 commented May 14, 2024

It looks like some of the tests are failing

Hmm, it's because we're not logged in to Azure for the unit tests. As it should be, really. But without logging in, we can't test CLI functionality.

Adding the azure-login bit to build-test.yml would be trivial, but it's a bit yucky in terms of clean unit tests. Hmm... thoughts, anyone (@danielrbradley)?

@danielrbradley
Copy link
Member

It blurs the lines a little between unit tests and integration tests a little but think that's probably a reasonable change for now to get it into CI. Perhaps it should be disabled by default by a flag or something so that locally just the unit tests (without external dependencies) are run by default.

@mikhailshilkov
Copy link
Member

Would it be hard to refactor the method to allow mocking of the Azure CLI dependency to turn these tests into pure unit tests of our code?

@thomas11
Copy link
Contributor Author

Would it be hard to refactor the method to allow mocking of the Azure CLI dependency to turn these tests into pure unit tests of our code?

The call out to az is unfortunately not in our code but in a dependency, and it's in the same method that handles the other auth mechanisms as well.

@thomas11 thomas11 force-pushed the tkappler/authconfig-tests branch from 9a9d557 to 927e535 Compare May 15, 2024 07:37
@mikhailshilkov
Copy link
Member

The call out to az is unfortunately not in our code but in a dependency, and it's in the same method that handles the other auth mechanisms as well.

Could we mock it out? Define an interface, pass the real implementation in the provider, pass a stub in the test, and only test our code (like the error logic that you added)?

@thomas11
Copy link
Contributor Author

The call out to az is unfortunately not in our code but in a dependency, and it's in the same method that handles the other auth mechanisms as well.

Could we mock it out? Define an interface, pass the real implementation in the provider, pass a stub in the test, and only test our code (like the error logic that you added)?

I don't see mocking as a good fit here. Like I said, most of the logic is in the dependency and the az tool, so if you mock it, the test just tests the mock. And that "public" != "usgovernment", which we already know. I'm in camp "mocking is overused" anyway.

Also, this whole issue is an aside I picked up from triage and I'm not planning to spend time for larger refactorings on it.

@thomas11 thomas11 force-pushed the tkappler/authconfig-tests branch 3 times, most recently from f27deb6 to 17ba847 Compare May 16, 2024 06:48
Copy link

codecov bot commented May 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.35%. Comparing base (0d8227f) to head (4a1870c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3285   +/-   ##
=======================================
  Coverage   55.35%   55.35%           
=======================================
  Files          66       66           
  Lines        9934     9934           
=======================================
  Hits         5499     5499           
  Misses       4001     4001           
  Partials      434      434           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thomas11 thomas11 force-pushed the tkappler/authconfig-tests branch from 17ba847 to 4a1870c Compare May 16, 2024 07:59
@thomas11 thomas11 merged commit 5a31c5a into master May 18, 2024
23 checks passed
@thomas11 thomas11 deleted the tkappler/authconfig-tests branch May 18, 2024 04:56
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.

3 participants