コード例 #1
0
ファイル: attachment-test.js プロジェクト: ciaranw/nopar
  "should create write stream and pipe to it": function () {
    this.stub(fs, "existsSync").returns(true);
    fs.createWriteStream.returns("MY_FD");

    this.attachFn(this.req, this.res);

    assert.called(fs.createWriteStream);
    assert.calledWith(fs.createWriteStream, "/path/test/test.tgz", {
      flags    : "w",
      encoding : null,
      mode     : "0660"
    });
    assert.called(this.req.pipe);
    assert.calledWith(this.req.pipe, "MY_FD");
  }
コード例 #2
0
ファイル: cache-storage.js プロジェクト: 160damage/enb
        it('should write data to stream split in chunks by prefix', function () {
            var writeStream = sinon.createStubInstance(fs.WriteStream);
            var storage = createCacheStorage_('/path/to/test_file.json');

            sandbox.stub(fs, 'createWriteStream');
            fs.createWriteStream.returns(writeStream);
            writeStream.on.returns(writeStream);

            storage.set('testPrefix', 'testKey', 'test_value');
            storage.saveAsync();

            expect(writeStream.write).to.be.calledWith('"testPrefix":');
            expect(writeStream.write).to.be.calledWith(JSON.stringify({
                testKey: 'test_value'
            }));
        });