|
@@ -1,6 +1,9 @@
|
|
|
package internal
|
|
|
|
|
|
import (
|
|
|
+ "io/ioutil"
|
|
|
+ "os"
|
|
|
+ "path/filepath"
|
|
|
"testing"
|
|
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
@@ -26,7 +29,14 @@ sent 7.55M bytes received 823.25M bytes 5.11M bytes/sec
|
|
|
total size is 1.33T speedup is 1,604.11
|
|
|
`
|
|
|
Convey("Log parser should work", t, func() {
|
|
|
- res := ExtractSizeFromRsyncLog([]byte(realLogContent))
|
|
|
+ tmpDir, err := ioutil.TempDir("", "tunasync")
|
|
|
+ So(err, ShouldBeNil)
|
|
|
+ defer os.RemoveAll(tmpDir)
|
|
|
+ logFile := filepath.Join(tmpDir, "rs.log")
|
|
|
+ err = ioutil.WriteFile(logFile, []byte(realLogContent), 0755)
|
|
|
+ So(err, ShouldBeNil)
|
|
|
+
|
|
|
+ res := ExtractSizeFromRsyncLog(logFile)
|
|
|
So(res, ShouldEqual, "1.33T")
|
|
|
})
|
|
|
}
|