瀏覽代碼

Add more test in FileSize

Vahid Sohrabloo 8 年之前
父節點
當前提交
7e0dbe8c48
共有 2 個文件被更改,包括 15 次插入6 次删除
  1. 14 0
      client_test.go
  2. 1 6
      ftp.go

+ 14 - 0
client_test.go

@@ -104,6 +104,20 @@ func testConn(t *testing.T, disableEPSV bool) {
 		t.Errorf("file size %q, expected %q", fileSize, 14)
 	}
 
+	data = bytes.NewBufferString("")
+	err = c.Stor("tset", data)
+	if err != nil {
+		t.Error(err)
+	}
+
+	fileSize, err = c.FileSize("tset")
+	if err != nil {
+		t.Error(err)
+	}
+	if fileSize != 0 {
+		t.Errorf("file size %q, expected %q", fileSize, 0)
+	}
+
 	fileSize, err = c.FileSize("not-found")
 	if err == nil {
 		t.Fatal("expected error, got nil")

+ 1 - 6
ftp.go

@@ -414,12 +414,7 @@ func (c *ServerConn) FileSize(path string) (int64, error) {
 		return 0, err
 	}
 
-	size, err := strconv.ParseInt(msg, 10, 64)
-	if err != nil {
-		return 0, err
-	}
-
-	return size, nil
+	return strconv.ParseInt(msg, 10, 64)
 }
 
 // Retr issues a RETR FTP command to fetch the specified file from the remote