Skip to content

Commit 455c91d

Browse files
committed
fix tests
1 parent 653e2ba commit 455c91d

File tree

3 files changed

+0
-46
lines changed

3 files changed

+0
-46
lines changed

routinegroup.go

-12
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@ func (g *RoutineGroup) Run(fn func()) {
2424
}()
2525
}
2626

27-
// RunSafe runs the given fn in RoutineGroup, and avoid panics.
28-
// Don't reference the variables from outside,
29-
// because outside variables can be changed by other goroutines
30-
func (g *RoutineGroup) RunSafe(fn func()) {
31-
g.waitGroup.Add(1)
32-
33-
GoSafe(func() {
34-
defer g.waitGroup.Done()
35-
fn()
36-
})
37-
}
38-
3927
// Wait waits all running functions to be done.
4028
func (g *RoutineGroup) Wait() {
4129
g.waitGroup.Wait()

routinegroup_test.go

-23
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package stream
22

33
import (
4-
"io/ioutil"
5-
"log"
6-
"sync"
74
"sync/atomic"
85
"testing"
96

@@ -23,23 +20,3 @@ func TestRoutineGroupRun(t *testing.T) {
2320

2421
assert.Equal(t, int32(3), count)
2522
}
26-
27-
func TestRoutingGroupRunSafe(t *testing.T) {
28-
log.SetOutput(ioutil.Discard)
29-
30-
var count int32
31-
group := NewRoutineGroup()
32-
var once sync.Once
33-
for i := 0; i < 3; i++ {
34-
group.RunSafe(func() {
35-
once.Do(func() {
36-
panic("")
37-
})
38-
atomic.AddInt32(&count, 1)
39-
})
40-
}
41-
42-
group.Wait()
43-
44-
assert.Equal(t, int32(2), count)
45-
}

stream_test.go

-11
Original file line numberDiff line numberDiff line change
@@ -262,17 +262,6 @@ func TestMap(t *testing.T) {
262262
},
263263
expect: 10,
264264
},
265-
{
266-
name: "mapper with panic",
267-
mapper: func(item interface{}) interface{} {
268-
v := item.(int)
269-
if v%2 == 0 {
270-
panic(v)
271-
}
272-
return v * v
273-
},
274-
expect: 10,
275-
},
276265
}
277266

278267
// Map(...) works even WithWorkers(0)

0 commit comments

Comments
 (0)