|
@@ -378,6 +378,22 @@ func TestMapReduceVoidCancelWithRemains(t *testing.T) {
|
|
assert.True(t, done.True())
|
|
assert.True(t, done.True())
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func TestMapReduceWithoutReducerWrite(t *testing.T) {
|
|
|
|
+ uids := []int{1, 2, 3}
|
|
|
|
+ res, err := MapReduce(func(source chan<- interface{}) {
|
|
|
|
+ for _, uid := range uids {
|
|
|
|
+ source <- uid
|
|
|
|
+ }
|
|
|
|
+ }, func(item interface{}, writer Writer, cancel func(error)) {
|
|
|
|
+ writer.Write(item)
|
|
|
|
+ }, func(pipe <-chan interface{}, writer Writer, cancel func(error)) {
|
|
|
|
+ drain(pipe)
|
|
|
|
+ // not calling writer.Write(...), should not panic
|
|
|
|
+ })
|
|
|
|
+ assert.Equal(t, ErrReduceNoOutput, err)
|
|
|
|
+ assert.Nil(t, res)
|
|
|
|
+}
|
|
|
|
+
|
|
func BenchmarkMapReduce(b *testing.B) {
|
|
func BenchmarkMapReduce(b *testing.B) {
|
|
b.ReportAllocs()
|
|
b.ReportAllocs()
|
|
|
|
|