Ensure directory exists in CreateDstDownloadMock and add comments.

pull/11223/head
Andriy Dzikh 2021-05-07 11:22:11 -07:00
parent 5e48738097
commit fbc041d2a1
1 changed files with 6 additions and 0 deletions

View File

@ -34,11 +34,17 @@ import (
)
var (
// DownloadMock is called instead of the download implementation if not nil.
DownloadMock func(src, dst string) error = nil
checkCache = os.Stat
)
// CreateDstDownloadMock is the default mock implementation of download.
func CreateDstDownloadMock(src, dst string) error {
if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
return errors.Wrap(err, "mkdir")
}
_, err := os.Create(dst)
return err
}