BVB Source Codes

parse-server Show GridStoreAdapter.js Source code

Return Download parse-server: download GridStoreAdapter.js Source code - Download parse-server Source code - Type:.js
  1. var MongoClient = require("mongodb").MongoClient;
  2. var GridStore = require("mongodb").GridStore;
  3.  
  4. var GridStoreAdapter = require("../src/Adapters/Files/GridStoreAdapter").GridStoreAdapter;
  5. var Config = require("../src/Config");
  6. var FilesController = require('../src/Controllers/FilesController').default;
  7.  
  8.  
  9. // Small additional tests to improve overall coverage
  10. describe_only_db('mongo')("GridStoreAdapter",() =>{
  11.   it("should properly instanciate the GridStore when deleting a file", (done) => {
  12.  
  13.     var databaseURI = 'mongodb://localhost:27017/parse';
  14.     var config = new Config(Parse.applicationId);
  15.     var gridStoreAdapter = new GridStoreAdapter(databaseURI);
  16.     var filesController = new FilesController(gridStoreAdapter);
  17.  
  18.     // save original unlink before redefinition
  19.     var originalUnlink = GridStore.prototype.unlink;
  20.  
  21.     var gridStoreMode;
  22.  
  23.     // new unlink method that will capture the mode in which GridStore was opened
  24.     GridStore.prototype.unlink = function() {
  25.  
  26.       // restore original unlink during first call
  27.       GridStore.prototype.unlink = originalUnlink;
  28.  
  29.       gridStoreMode = this.mode;
  30.  
  31.       return originalUnlink.call(this);
  32.     };
  33.  
  34.  
  35.     filesController.createFile(config, 'myFilename.txt', 'my file content', 'text/plain')
  36.       .then(myFile => {
  37.  
  38.         return MongoClient.connect(databaseURI)
  39.           .then(database => {
  40.  
  41.             // Verify the existance of the fs.files document
  42.             return database.collection('fs.files').count().then(count => {
  43.               expect(count).toEqual(1);
  44.               return database;
  45.             });
  46.           })
  47.           .then(database => {
  48.  
  49.             // Verify the existance of the fs.files document
  50.             return database.collection('fs.chunks').count().then(count => {
  51.               expect(count).toEqual(1);
  52.               return database.close();
  53.             });
  54.           })
  55.           .then(() => {
  56.             return filesController.deleteFile(config, myFile.name);
  57.           });
  58.       })
  59.       .then(() => {
  60.         return         MongoClient.connect(databaseURI)
  61.           .then(database => {
  62.  
  63.             // Verify the existance of the fs.files document
  64.             return database.collection('fs.files').count().then(count => {
  65.               expect(count).toEqual(0);
  66.               return database;
  67.             });
  68.           })
  69.           .then(database => {
  70.  
  71.             // Verify the existance of the fs.files document
  72.             return database.collection('fs.chunks').count().then(count => {
  73.               expect(count).toEqual(0);
  74.               return database.close();
  75.             });
  76.           });
  77.       })
  78.       .then(() => {
  79.         // Verify that gridStore was opened in read only mode
  80.         expect(gridStoreMode).toEqual('r');
  81.  
  82.         done();
  83.       })
  84.       .catch(fail);
  85.  
  86.   })
  87. });
  88.  
downloadGridStoreAdapter.js Source code - Download parse-server Source code
Related Source Codes/Software:
react-boilerplate - 2017-06-07
webtorrent - Streaming torrent client for the web ... 2017-06-06
machine-learning-for-software-engineers - A complete daily plan for studying to become a mac... 2017-06-06
upterm - A terminal emulator for the 21st century. 2017-06-06
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
ionicons - The premium icon font for Ionic ... 2017-06-07
storybook - 2017-06-07
prettier - Prettier is an opinionated JavaScript formatter. ... 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top