Fix Docker os.Rename invalid cross-device link issue (#386)

* Adds new file.Move func to address a bug with Golang/Docker volumes when using os.Rename

Also uses TempDir for tests instead of live directories and increases test coverage for file.Write

* Goimport the imports

* Make usage of file package name consistent so it no longer clashes with vars

* Remove outputFile if io.Copy fails
This commit is contained in:
Adrian Gallagher
2019-11-28 11:56:05 +11:00
committed by GitHub
parent 63191ce3ec
commit e20d204b19
15 changed files with 205 additions and 50 deletions

View File

@@ -13,8 +13,8 @@ import (
"strings"
"sync"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/common/crypto"
"github.com/thrasher-corp/gocryptotrader/common/file"
)
// HTTPResponse defines expected response from the end point including request
@@ -212,7 +212,7 @@ func HTTPRecord(res *http.Response, service string, respContents []byte) error {
return err
}
return common.WriteFile(fileout, payload)
return file.Write(fileout, payload)
}
// GetFilteredHeader filters excluded http headers for insertion into a mock

View File

@@ -15,6 +15,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/common/crypto"
"github.com/thrasher-corp/gocryptotrader/common/file"
)
// DefaultDirectory defines the main mock directory
@@ -56,7 +57,7 @@ func NewVCRServer(path string) (string, *http.Client, error) {
return "", nil, jErr
}
err = common.WriteFile(path, data)
err = file.Write(path, data)
if err != nil {
return "", nil, err
}