tests: Unit tests and fixes for copyBuffer. (#2333)

- Unit tests for copyBuffer.
- Shadowing fix for copyBuffer.
This commit is contained in:
karthic rao
2016-07-31 02:06:43 +05:30
committed by Harshavardhana
parent 8d090a20ce
commit 9baf599c91
3 changed files with 125 additions and 4 deletions
+3 -4
View File
@@ -163,10 +163,9 @@ func copyBuffer(writer io.Writer, disk StorageAPI, volume string, path string, b
for {
n, err := disk.ReadFile(volume, path, startOffset, buf)
if n > 0 {
var m int
m, err = writer.Write(buf[:n])
if err != nil {
return err
m, wErr := writer.Write(buf[:n])
if wErr != nil {
return wErr
}
if int64(m) != n {
return io.ErrShortWrite