-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain_test.go
More file actions
47 lines (36 loc) · 841 Bytes
/
main_test.go
File metadata and controls
47 lines (36 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package fetchall
import (
"io"
"testing"
"appengine/aetest"
)
// const bigFileUrl = "http://ipv4.download.thinkbroadband.com/50MB.zip"
const bigFileUrl = "http://mirror.internode.on.net/pub/test/50meg.test"
func TestLoadingHugefile(t *testing.T) {
c, err := aetest.NewContext(nil)
if err != nil {
t.Fatal(err)
}
client := Client(c)
r, err := client.Get(bigFileUrl)
if err != nil {
t.Fatal(err)
}
defer r.Body.Close()
buf := make([]byte, 3*1024*1024) // 3 MB
totalReadBytes := 0
for {
readBytes, err := r.Body.Read(buf)
if err == io.EOF {
break
}
if err != nil {
t.Fatal(err)
}
totalReadBytes += readBytes
}
t.Logf("read %d bytes in total", totalReadBytes)
if totalReadBytes < 32*1024*1024 {
t.Errorf("expected to read more than 32 MB but just read ~ %d MB", totalReadBytes/1014/1014)
}
}