瀏覽代碼

fix util_test

zyx 5 年之前
父節點
當前提交
2c33380ce0
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. 11 1
      internal/util_test.go

+ 11 - 1
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")
 	})
 }