Ensure directory exists in CreateDstDownloadMock and add comments.
parent
5e48738097
commit
fbc041d2a1
|
@ -34,11 +34,17 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// DownloadMock is called instead of the download implementation if not nil.
|
||||||
DownloadMock func(src, dst string) error = nil
|
DownloadMock func(src, dst string) error = nil
|
||||||
checkCache = os.Stat
|
checkCache = os.Stat
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CreateDstDownloadMock is the default mock implementation of download.
|
||||||
func CreateDstDownloadMock(src, dst string) error {
|
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)
|
_, err := os.Create(dst)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue