Move consumeSlow() under test utils

Signed-off-by: Tõnis Tiigi <tonistiigi@gmail.com> (github: tonistiigi)
Upstream-commit: 8a81c462722c7158e481f974f628843e7c172158
Component: engine
This commit is contained in:
Tonis Tiigi
2014-10-30 20:52:13 +02:00
parent abcf5d1b6e
commit 55acba12a1
2 changed files with 16 additions and 16 deletions

View File

@ -253,3 +253,19 @@ func makeRandomString(n int) string {
}
return string(b)
}
func consumeSlow(reader io.Reader, chunkSize int, interval time.Duration) (n int, err error) {
buffer := make([]byte, chunkSize)
for {
var readBytes int
readBytes, err = reader.Read(buffer)
n += readBytes
if err != nil {
if err == io.EOF {
err = nil
}
return
}
time.Sleep(interval)
}
}