Test for ObjectLayer.GetObject() (#2153)

This commit is contained in:
karthic rao
2016-07-09 06:56:04 +05:30
committed by Harshavardhana
parent 778b870b77
commit b0c180b77c
2 changed files with 205 additions and 1 deletions
+30 -1
View File
@@ -59,7 +59,7 @@ type TestErrHandler interface {
const (
// singleNodeTestStr is the string which is used as notation for Single node ObjectLayer in the unit tests.
singleNodeTestStr string = "SingleNode"
singleNodeTestStr string = "FS"
// xLTestStr is the string which is used as notation for XL ObjectLayer in the unit tests.
xLTestStr string = "XL"
)
@@ -353,6 +353,35 @@ func getRandomBucketName() string {
}
// NewEOFWriter returns a Writer that writes to w,
// but returns EOF error after writing n bytes.
func NewEOFWriter(w io.Writer, n int64) io.Writer {
return &EOFWriter{w, n}
}
type EOFWriter struct {
w io.Writer
n int64
}
// io.Writer implementation desgined to error out with io.EOF after reading
func (t *EOFWriter) Write(p []byte) (n int, err error) {
if t.n <= 0 {
return -1, io.EOF
}
// real write
n = len(p)
if int64(n) > t.n {
n = int(t.n)
}
n, err = t.w.Write(p[0:n])
t.n -= int64(n)
if err == nil {
n = len(p)
}
return
}
// queryEncode - encodes query values in their URL encoded form.
func queryEncode(v url.Values) string {
if v == nil {