git ssb

2+

Dominic / pull-stream



Commit f759c061511a1a7ccb4677cd693db433280ddacd

Add failing tests for cases discussed in #32

Jan Bölsche committed on 9/12/2015, 4:24:24 PM
Parent: 8aaed914fd9b931e56aa5467f7f07c9c5f1a9a30

Files changed

test/flatten.jschanged
test/flatten.jsView
@@ -53,20 +53,50 @@
5353
5454 })
5555
5656 test('flatten stream of broken streams', function (t) {
57- var _err = new Error('I am broken');
57+ var _err = new Error('I am broken'), sosEnded
5858 pull(
5959 pull.values([
6060 pull.Source(function read(abort, cb) {
6161 cb(_err)
6262 })
63- ]),
63+ ], function(err) {
64+ sosEnded = err;
65+ }),
6466 pull.flatten(),
6567 pull.onEnd(function (err) {
6668 t.equal(err, _err)
67- t.end()
69+ process.nextTick(function() {
70+ t.equal(sosEnded, true, 'should abort stream of streams')
71+ t.end()
72+ })
6873 })
6974 )
75+})
7076
77+test('abort flatten', function (t) {
78+ var sosEnded, s1Ended, s2Ended
79+ var read = pull(
80+ pull.values([
81+ pull.values([1,2], function(err) {s1Ended = err}),
82+ pull.values([3,4], function(err) {s2Ended = err}),
83+ ], function(err) {
84+ sosEnded = err;
85+ }),
86+ pull.flatten()
87+ )
88+
89+ read(null, function(err, data) {
90+ t.notOk(err)
91+ t.equal(data,1)
92+ read(true, function(err, data) {
93+ t.equal(err, true)
94+ process.nextTick(function() {
95+ t.equal(s1Ended, true, 'should abort current nested stream')
96+ t.equal(s2Ended, undefined, 'should not abort queued nested stream')
97+ t.end()
98+ })
99+ })
100+ })
71101 })
72102

Built with git-ssb-web