-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller_test.go
71 lines (59 loc) · 1.57 KB
/
controller_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
70
71
package richkago
import "testing"
// TestNewController test example that builds a new controller
func TestNewController(t *testing.T) {
controller := NewController()
if controller == nil {
t.Error("controller is nil")
return
}
}
// TestController_UpdateProgress test example that updates progress
func TestController_UpdateProgress(t *testing.T) {
controller := NewController()
controller.totalSize = 1000
controller.UpdateProgress(100, "1")
if controller.Progress() != 10 {
t.Error("progress is wrong", controller.Progress())
return
}
if controller.Status() != 1 {
t.Error("status is wrong", controller.Status())
return
}
}
// TestController_Pause test example that pause a progress
func TestController_Pause(t *testing.T) {
controller := NewController()
controller.totalSize = 1000
controller.UpdateProgress(100, "1")
if controller.Progress() != 10 {
t.Error("progress is wrong", controller.Progress())
return
}
controller.Pause()
if controller.Status() != -2 {
t.Error("status is wrong", controller.Status())
return
}
}
// TestController_Unpause test example that unpause a progress
func TestController_Unpause(t *testing.T) {
controller := NewController()
controller.totalSize = 1000
controller.UpdateProgress(100, "1")
if controller.Progress() != 10 {
t.Error("progress is wrong", controller.Progress())
return
}
controller.Pause()
if controller.Status() != -2 {
t.Error("status is wrong", controller.Status())
return
}
controller.Unpause()
if controller.Status() != 1 {
t.Error("status is wrong", controller.Status())
return
}
}