mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-16 23:16:48 +00:00
Add RemoveFile common function
Also cleans up left over test files
This commit is contained in:
@@ -383,7 +383,8 @@ func OutputCSV(path string, data [][]string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
defer writer.Flush()
|
||||
writer.Flush()
|
||||
file.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -420,6 +421,11 @@ func WriteFile(file string, data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveFile removes a file
|
||||
func RemoveFile(file string) error {
|
||||
return os.Remove(file)
|
||||
}
|
||||
|
||||
// GetURIPath returns the path of a URL given a URI
|
||||
func GetURIPath(uri string) string {
|
||||
urip, err := url.Parse(uri)
|
||||
|
||||
@@ -652,6 +652,22 @@ func TestWriteFile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoveFile(t *testing.T) {
|
||||
TestWriteFile(t)
|
||||
path := "../testdata/writefiletest"
|
||||
err := RemoveFile(path)
|
||||
if err != nil {
|
||||
t.Errorf("Test failed. Common RemoveFile error: %s", err)
|
||||
}
|
||||
|
||||
TestOutputCSV(t)
|
||||
path = "../testdata/dump"
|
||||
err = RemoveFile(path)
|
||||
if err != nil {
|
||||
t.Errorf("Test failed. Common RemoveFile error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetURIPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
// mapping of input vs expected result
|
||||
|
||||
Reference in New Issue
Block a user