-
Notifications
You must be signed in to change notification settings - Fork 46
/
chunks_test.go
56 lines (40 loc) · 1.04 KB
/
chunks_test.go
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
48
49
50
51
52
53
54
55
56
package got
import (
"testing"
)
func TestChunksLength(t *testing.T) {
d := &Download{
URL: "https://proof.ovh.net/files/10Mb.dat",
MinChunkSize: 5242870,
}
if err := d.Init(); err != nil {
t.Error(err)
return
}
chunk0 := Chunk{
Start: 0,
End: 5242870,
}
// Last chunk should not have end,
// So the server must respond with the remaining content starting form 5242871
chunk1 := Chunk{
Start: 5242871,
End: 10485759,
}
if d.info.Rangeable == false {
t.Errorf("Chunk information could not be retrieved for the test file: %s", d.URL)
return
}
if d.chunks[0].Start != 0 {
t.Errorf("First chunk should start from 0, but got %d", d.chunks[0].Start)
}
if chunk0.End != d.chunks[0].End {
t.Errorf("Chunk 0 expecting: %d but got: %d", chunk0.End, d.chunks[0].End)
}
if d.chunks[1].Start != 5242871 {
t.Errorf("Second chunk should start from: 5242871, but got %d", d.chunks[1].Start)
}
if chunk1.End != d.chunks[1].End {
t.Errorf("Chunk 1 expecting: %d but got: %d", chunk1.End, d.chunks[1].End)
}
}