File tree 3 files changed +72
-14
lines changed
3 files changed +72
-14
lines changed Original file line number Diff line number Diff line change 8
8
"github.com/stretchr/testify/assert"
9
9
)
10
10
11
- func TestExample ( t * testing. T ) {
11
+ func Example ( ) {
12
12
f , counter := New (), 0
13
13
showLevel := func () {
14
14
counter ++
@@ -40,11 +40,71 @@ func TestExample(t *testing.T) {
40
40
f .Limit (10 )
41
41
// wait and add counter
42
42
f .Run ()
43
+ // Unordered output:
44
+ // 0
45
+ // 1
46
+ // 2
47
+ // 3
48
+ // 4
49
+ // 5
50
+ // 6
51
+ // 7
52
+ // 8
53
+ // 9
54
+ // 10
55
+ // 11
56
+ // 12
57
+ // 13
58
+ // 14
59
+ // 15
60
+ // 16
61
+ // 17
62
+ // 18
63
+ // 19
64
+ // 0
65
+ // 1
66
+ // 2
67
+ // 3
68
+ // 4
69
+ // 5
70
+ // 6
71
+ // 7
72
+ // 8
73
+ // 9
74
+ // 10
75
+ // 11
76
+ // 12
77
+ // 13
78
+ // 14
79
+ // 15
80
+ // 16
81
+ // 17
82
+ // 18
83
+ // 19
84
+ // level 1
85
+ // level 2
43
86
}
44
87
45
- func TestNilFunc ( t * testing. T ) {
88
+ func Example_NilFunc ( ) {
46
89
reset ()
47
90
New ().With (nil ).Next (nil ).Run ()
91
+ // Output:
92
+ // flow error: nil job
93
+ // flow error: nil job
94
+ }
95
+
96
+ func Example_SilentMode () {
97
+ reset ()
98
+ New ().With (func () {
99
+ panic ("u can see me" )
100
+ }).Run ()
101
+
102
+ SilentMode = true
103
+ New ().With (func () {
104
+ panic ("u can not see me" )
105
+ }).Run ()
106
+ // Output:
107
+ // flow panic: u can see me
48
108
}
49
109
50
110
func TestConcurrent (t * testing.T ) {
@@ -147,18 +207,6 @@ func TestLimit(t *testing.T) {
147
207
f .Run ()
148
208
}
149
209
150
- func TestSilentMode (t * testing.T ) {
151
- reset ()
152
- New ().With (func () {
153
- panic ("u can see me" )
154
- }).Run ()
155
-
156
- SilentMode = true
157
- New ().With (func () {
158
- panic ("u can not see me" )
159
- }).Run ()
160
- }
161
-
162
210
func TestGlobalLimit (t * testing.T ) {
163
211
reset ()
164
212
Limit (4 )
Original file line number Diff line number Diff line change
1
+ module github.com/BouncyElf/flow
2
+
3
+ require github.com/stretchr/testify v1.3.0
Original file line number Diff line number Diff line change
1
+ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 =
2
+ github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
3
+ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM =
4
+ github.com/pmezard/go-difflib v1.0.0 /go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4 =
5
+ github.com/stretchr/objx v0.1.0 /go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME =
6
+ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q =
7
+ github.com/stretchr/testify v1.3.0 /go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI =
You can’t perform that action at this time.
0 commit comments