operator/pkg: unit test utilities
Description
In this commit, we unit test utilities on downloader operations and unpacking tar files.
What type of PR is this?
Which issue(s) this PR fixes: Part of #5491.
Does this PR introduce a user-facing change?:
NONE
:warning: Please install the to ensure uploads and comments are reliably processed by Codecov.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 38.60%. Comparing base (
c16e52a) to head (49eb96b). Report is 71 commits behind head on master.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@ Coverage Diff @@
## master #5675 +/- ##
==========================================
+ Coverage 35.85% 38.60% +2.75%
==========================================
Files 647 650 +3
Lines 45070 55122 +10052
==========================================
+ Hits 16158 21281 +5123
- Misses 27664 32480 +4816
- Partials 1248 1361 +113
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 38.60% <100.00%> (+2.75%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
When I run the ut in the windows, it report error:
=== RUN TestDownloadFile/DownloadFile_FileDownlaoded_ util_test.go:229: failed to prep before downloading the file, got: failed to create temp file: open C:\Users\C00502~1\AppData\Local\Temp/tempfile-*.txt: The filename, directory name, or volume label syntax is incorrect. util_test.go:236: unexpected error, got: failed to download file. url: https://www.example.com/test-file code: 503 util_test.go:242: failed to verify the actual of download of file: failed to read file: open C:\Users\C00502~1\AppData\Local\Temp/tempfile-*.txt: The filename, directory name, or volume label syntax is incorrect. --- FAIL: TestDownloadFile (0.00s) --- PASS: TestDownloadFile/DownloadFile_UrlIsNotFound_FailedToGetResponse (0.00s) --- PASS: TestDownloadFile/DownloadFile_ServiceIsUnavailable_FailedToReachTheService (0.00s) --- FAIL: TestDownloadFile/DownloadFile_FileDownlaoded_ (0.00s)
@XiShanYongYe-Chang Good catch! The current unit testing code assumed it was only targeting the Linux platform, so it used "/" as a separator. I've updated it to use filepath.Join for platform independence. That said, I haven't been able to test it on Windows since I don't have access to one. Could you please test it again and let me know? 🙏
Okay, let me have a retry.
I've updated the last commit. @XiShanYongYe-Chang, I realized that I forgot to replace one instance where "/" was used. 😁 Please pull the latest commit! 🙏
It still failed:
=== RUN TestDownloadFile/DownloadFile_FileDownlaoded_
util_test.go:230: failed to prep before downloading the file, got: failed to create temp file: open C:\Users\C00502~1\AppData\Local\Temp\tempfile-*.txt: The filename, directory name, or volume label syntax is incorrect.
util_test.go:237: unexpected error, got: failed to download file. url: https://www.example.com/test-file code: 503
util_test.go:243: failed to verify the actual of download of file: failed to read file: open C:\Users\C00502~1\AppData\Local\Temp\tempfile-*.txt: The filename, directory name, or volume label syntax is incorrect.
--- FAIL: TestDownloadFile (0.00s)
--- PASS: TestDownloadFile/DownloadFile_UrlIsNotFound_FailedToGetResponse (0.00s)
--- PASS: TestDownloadFile/DownloadFile_ServiceIsUnavailable_FailedToReachTheService (0.00s)
--- FAIL: TestDownloadFile/DownloadFile_FileDownlaoded_ (0.00s)
/assign
@XiShanYongYe-Chang, I've updated the commit. I believe the issue is primarily with the naming of the file tempfile-*.txt, but I'm still not 100% sure. Could you please try it again and let me know how it goes? 🙏
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: XiShanYongYe-Chang
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~operator/OWNERS~~ [XiShanYongYe-Chang]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment