@@ -2,6 +2,7 @@ package progress
2
2
3
3
import (
4
4
"testing"
5
+ "time"
5
6
6
7
"github.com/stretchr/testify/assert"
7
8
)
@@ -11,40 +12,48 @@ func TestSortBy(t *testing.T) {
11
12
{Message : "Downloading File # 2" , Total : 1000 , value : 300 },
12
13
{Message : "Downloading File # 1" , Total : 1000 , value : 100 },
13
14
{Message : "Downloading File # 3" , Total : 1000 , value : 500 },
15
+ {Message : "Downloading File # 4" , Total : 1000 , value : 300 , timeStart : time .Now ()},
14
16
}
15
17
16
18
SortByNone .Sort (trackers )
17
19
assert .Equal (t , "Downloading File # 2" , trackers [0 ].Message )
18
20
assert .Equal (t , "Downloading File # 1" , trackers [1 ].Message )
19
21
assert .Equal (t , "Downloading File # 3" , trackers [2 ].Message )
22
+ assert .Equal (t , "Downloading File # 4" , trackers [3 ].Message )
20
23
21
24
SortByMessage .Sort (trackers )
22
25
assert .Equal (t , "Downloading File # 1" , trackers [0 ].Message )
23
26
assert .Equal (t , "Downloading File # 2" , trackers [1 ].Message )
24
27
assert .Equal (t , "Downloading File # 3" , trackers [2 ].Message )
28
+ assert .Equal (t , "Downloading File # 4" , trackers [3 ].Message )
25
29
26
30
SortByMessageDsc .Sort (trackers )
27
- assert .Equal (t , "Downloading File # 3" , trackers [0 ].Message )
28
- assert .Equal (t , "Downloading File # 2" , trackers [1 ].Message )
29
- assert .Equal (t , "Downloading File # 1" , trackers [2 ].Message )
31
+ assert .Equal (t , "Downloading File # 4" , trackers [0 ].Message )
32
+ assert .Equal (t , "Downloading File # 3" , trackers [1 ].Message )
33
+ assert .Equal (t , "Downloading File # 2" , trackers [2 ].Message )
34
+ assert .Equal (t , "Downloading File # 1" , trackers [3 ].Message )
30
35
31
36
SortByPercent .Sort (trackers )
32
37
assert .Equal (t , "Downloading File # 1" , trackers [0 ].Message )
33
38
assert .Equal (t , "Downloading File # 2" , trackers [1 ].Message )
34
- assert .Equal (t , "Downloading File # 3" , trackers [2 ].Message )
39
+ assert .Equal (t , "Downloading File # 4" , trackers [2 ].Message )
40
+ assert .Equal (t , "Downloading File # 3" , trackers [3 ].Message )
35
41
36
42
SortByPercentDsc .Sort (trackers )
37
43
assert .Equal (t , "Downloading File # 3" , trackers [0 ].Message )
38
- assert .Equal (t , "Downloading File # 2" , trackers [1 ].Message )
39
- assert .Equal (t , "Downloading File # 1" , trackers [2 ].Message )
44
+ assert .Equal (t , "Downloading File # 4" , trackers [1 ].Message )
45
+ assert .Equal (t , "Downloading File # 2" , trackers [2 ].Message )
46
+ assert .Equal (t , "Downloading File # 1" , trackers [3 ].Message )
40
47
41
48
SortByValue .Sort (trackers )
42
49
assert .Equal (t , "Downloading File # 1" , trackers [0 ].Message )
43
50
assert .Equal (t , "Downloading File # 2" , trackers [1 ].Message )
44
- assert .Equal (t , "Downloading File # 3" , trackers [2 ].Message )
51
+ assert .Equal (t , "Downloading File # 4" , trackers [2 ].Message )
52
+ assert .Equal (t , "Downloading File # 3" , trackers [3 ].Message )
45
53
46
54
SortByValueDsc .Sort (trackers )
47
55
assert .Equal (t , "Downloading File # 3" , trackers [0 ].Message )
48
- assert .Equal (t , "Downloading File # 2" , trackers [1 ].Message )
49
- assert .Equal (t , "Downloading File # 1" , trackers [2 ].Message )
56
+ assert .Equal (t , "Downloading File # 4" , trackers [1 ].Message )
57
+ assert .Equal (t , "Downloading File # 2" , trackers [2 ].Message )
58
+ assert .Equal (t , "Downloading File # 1" , trackers [3 ].Message )
50
59
}
0 commit comments