feat: [PIPE-20976]: Refactor Downloader and Add UTs #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With the intent of improving code quality of the
download
package, in this PR we refactor it (renaming it todownloader
). TheDownloader
struct becomes like this:So that instead of having a the
Downloader
provide a singleDownload
method, we make it provide 2 distinct methods, one for cloning repositories, and another for downloading executable files:In this way, we let the caller figure out which kind of download it wants to carry out, and call the appropriate method. We can then avoid the
Downloader
class containing mixed logics for cloning repositories and downloading executables, thus improving maintainability of the codebase.We have also moved the common functionality, used by both
repoDownloader
andexecutableDownloader
, toutil.go
file, and added UTs for files in thedownloader
package.TESTING:
All tests in the repo are passing. CGI tasks are also working fine if you change the
Task
structure to usejson.RawMessage
instead of[]byte
: