-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprogress_test.go
69 lines (67 loc) · 1.26 KB
/
progress_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
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import "testing"
func TestProgress(t *testing.T) {
cases := []struct {
input event
expectProcessed float64
expectFound float64
expectOk bool
}{
{
event{
Type: "progress",
Payload: eventPayload{
Progress: "Processando 1/2",
},
},
1.0,
2.0,
true,
},
{
event{
Type: "progress",
Payload: eventPayload{
Progress: "Processando x/2",
},
},
0,
0,
false,
},
{
event{
Type: "else",
Payload: eventPayload{
Progress: "Processando 1/2",
},
},
0,
0,
false,
},
{
event{
Type: "progress",
Payload: eventPayload{
Progress: "2020-04-24 15:12:43 [MSG] [indexer.process.ProgressConsole] Processando 2153/3591 (7%) 64GB/h Termino em 0h 55m 9s",
},
},
2153,
3591,
true,
},
}
for _, c := range cases {
processed, found, ok := progress(c.input)
if processed != c.expectProcessed {
t.Errorf("expected: %v, got %v, input: %x", c.expectProcessed, processed, c.input)
}
if found != c.expectFound {
t.Errorf("expected: %v, got %v, input: %x", c.expectFound, found, c.input)
}
if ok != c.expectOk {
t.Errorf("expected: %v, got %v, input: %x", c.expectOk, ok, c.input)
}
}
}