fake.returns({ restart: fake.resolves(true), exec: ({ Cmd }) => { const mockedStream = new stream.Readable(); return fake.resolves({ start: sinon.stub().yields(Cmd[0] === 'fail' ? 'error' : null, mockedStream), })(); }, })
describe('#getFileStream', function getFileStreamSuite() { this.timeout(timeout); before(function before() { // utils.handleRatelimit(bot, 'getFileStream', this); }); it('should get a file stream', function test(done) { const fileStream = bot.getFileStream(FILE_ID); assert.ok(fileStream instanceof stream.Readable); assert.equal(fileStream.path, FILE_ID); fileStream.on('info', (info) => { assert.ok(info); assert.ok(utils.isTelegramFileURI(info.uri), `${info.uri} is not a file URI`); fileStream.pipe(concat(function readFile(buffer) { buffer.equals(fs.readFileSync(FILE_PATH)); // sync :( return done(); })); }); }); });
transit.opts.maxChunkSize = 100; let randomData = crypto.randomBytes(1024); let stream = new Stream.Readable({ read() {} });
it("should send stream chunks", () => { transit.publish.mockClear(); let stream = new Stream.Readable({ read() {} });
}); const stream = new Stream.Readable({ read() {} }); .then(() => b1.call("file.get")) .then(res => { expect(res).toBeInstanceOf(Stream.Readable); res.on("data", msg => FLOW.push(msg.toString())); res.on("error", err => FLOW.push("<ERROR:" + err.message + ">")); .then(() => b1.call("file.get")) .then(res => { expect(res).toBeInstanceOf(Stream.Readable); res.on("data", msg => FLOW.push(msg.toString())); res.on("error", err => FLOW.push("<ERROR:" + err.message + ">"));
actions: { parse(ctx) { const pass = new Stream.Readable({ objectMode: true, read() {} const stream = new Stream.Readable({ objectMode: true, read() {} .then(() => b1.call("csv.parse", stream)) .then(res => { expect(res).toBeInstanceOf(Stream.Readable); expect(res.readableObjectMode === true || (res._readableState && res._readableState.objectMode === true)).toBe(true); res.on("data", msg => FLOW.push(msg)); const stream = new Stream.Readable({ objectMode: true, read() {} .then(() => b1.call("csv.parse", stream)) .then(res => { expect(res).toBeInstanceOf(Stream.Readable); expect(res.readableObjectMode === true || (res._readableState && res._readableState.objectMode === true)).toBe(true); res.on("data", msg => FLOW.push(msg));
let stream = new Stream.Readable({ objectMode: true, read() {} store(ctx) { expect(FLOW).toEqual([]); expect(ctx.params).toBeInstanceOf(Stream.Readable); expect(ctx.params.readableObjectMode === true || (ctx.params._readableState && ctx.params._readableState.objectMode === true)).toBe(true); ctx.params.on("data", msg => FLOW.push(msg)); stream = new Stream.Readable({ objectMode: true, read() {}
transit.opts.maxChunkSize = 100; let randomData = crypto.randomBytes(1024); let stream = new Stream.Readable({ read() {} });
it("should send stream error", () => { transit.publish.mockClear(); let stream = new Stream.Readable({ read() {} });
}); const stream = new Stream.Readable({ objectMode: true, read() {} .then(() => b1.call("db.query")) .then(res => { expect(res).toBeInstanceOf(Stream.Readable); expect(res.readableObjectMode === true || (res._readableState && res._readableState.objectMode === true)).toBe(true); res.on("data", msg => FLOW.push(msg)); .then(() => b1.call("db.query")) .then(res => { expect(res).toBeInstanceOf(Stream.Readable); expect(res.readableObjectMode === true || (res._readableState && res._readableState.objectMode === true)).toBe(true); res.on("data", msg => FLOW.push(msg));
it("should send stream objects", () => { transit.publish.mockClear(); let stream = new Stream.Readable({ objectMode: true, read() {}
it("should send stream chunks", () => { transit.publish.mockClear(); let stream = new Stream.Readable({ read() {} });
it("should send stream chunks", () => { transit.publish.mockClear(); let stream = new Stream.Readable({ read() {} });
fake.returns({ restart: fake.resolves(true), exec: ({ Cmd }) => { const mockedStream = new stream.Readable(); return fake.resolves({ start: sinon.stub().yields(Cmd[0] === 'fail' ? 'error' : null, mockedStream), })(); }, })