fix: allow to use an entreprise GIthub instance and an authentication token in the same time again
Hello,
This PR fix a regression introduced in https://github.com/argoproj/argo-cd/pull/21292. Before that, we were able to use both an URL and also an authentication token.
Best Regards.
:x: Preview Environment undeployed from Bunnyshell
Available commands (reply to this comment):
- :rocket:
/bns:deployto deploy the environment
Should this be unit tested?
Codecov Report
Attention: Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.
Please upload report for BASE (
master@0484f9f). Learn more about missing BASE report. Report is 27 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| applicationset/services/pull_request/github.go | 72.72% | 2 Missing and 1 partial :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #23129 +/- ##
=========================================
Coverage ? 60.05%
=========================================
Files ? 343
Lines ? 57887
Branches ? 0
=========================================
Hits ? 34766
Misses ? 20339
Partials ? 2782
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hello @crenshaw-dev,
I tried hard to implement an unit test without changing the definition of the NewGithubService function.
First I tried to check if the URL and the token were correctly set by inspecting the internals of the http.Client, but I couldn't correctly test for the token and it was brittle. Then I tried with a test HTTP server, but I couldn't make it work this way also.
Therefore I ended adding an optional http.Client argument to the NewGithubService function, this let me mock the Transport so I can inspect both the URL and the token.
Best Regards.
I confirm this fixes the bug. The code looks good to me as well...