diff --git a/internal/util_test.go b/internal/util_test.go index 27b6641..f449029 100644 --- a/internal/util_test.go +++ b/internal/util_test.go @@ -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") }) }