git ssb

2+

Dominic / pull-stream



Commit 77e8971d09fb121162d025a7851aca84b3d5562f

Add test that fails when async-map is aborted while reading from an async source

Jan Bölsche authored on 4/23/2016, 10:33:53 AM
Dominic Tarr committed on 4/24/2016, 3:57:21 AM
Parent: fd5a385051c12f9b5331d8d77e51257f6d93bdc5

Files changed

test/async-map.jschanged
test/async-map.jsView
@@ -41,8 +41,38 @@
4141 })
4242
4343 })
4444
45+tape('abort async map (async source)', function (t) {
46+ var err = new Error('abort')
47+ t.plan(2)
48+
49+ var read = pull(
50+ function(err, cb) {
51+ setImmediate(function() {
52+ if (err) return cb(err)
53+ cb(null, 'x')
54+ })
55+ },
56+ pull.asyncMap(function (data, cb) {
57+ setImmediate(function () {
58+ cb(null, data)
59+ })
60+ })
61+ )
62+
63+ read(null, function (end) {
64+ if(!end) throw new Error('expected read to end')
65+ t.ok(end, "read's callback")
66+ })
67+
68+ read(err, function (end) {
69+ if(!end) throw new Error('expected abort to end')
70+ t.ok(end, "Abort's callback")
71+ t.end()
72+ })
73+
74+})
4575 tape('asyncMap aborts when map errors', function (t) {
4676 t.plan(2)
4777 var ERR = new Error('abort')
4878 pull(

Built with git-ssb-web