mirror of
https://github.com/pgsty/minio.git
synced 2026-07-24 22:46:16 +03:00
Test for ObjectLayer.GetObject() (#2153)
This commit is contained in:
committed by
Harshavardhana
parent
778b870b77
commit
b0c180b77c
+30
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user