-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves Files adapters to external packages
- Loading branch information
1 parent
ee8f85b
commit 00f2aac
Showing
12 changed files
with
42 additions
and
536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,30 @@ | ||
var FilesController = require('../src/Controllers/FilesController').FilesController; | ||
var GridStoreAdapter = require("../src/Adapters/Files/GridStoreAdapter").GridStoreAdapter; | ||
var S3Adapter = require("../src/Adapters/Files/S3Adapter").S3Adapter; | ||
var GCSAdapter = require("../src/Adapters/Files/GCSAdapter").GCSAdapter; | ||
var FileSystemAdapter = require("../src/Adapters/Files/FileSystemAdapter").FileSystemAdapter; | ||
var Config = require("../src/Config"); | ||
|
||
var FCTestFactory = require("./FilesControllerTestFactory"); | ||
var FilesController = require('../src/Controllers/FilesController').default; | ||
|
||
|
||
// Small additional tests to improve overall coverage | ||
describe("FilesController",()=>{ | ||
|
||
// Test the grid store adapter | ||
var gridStoreAdapter = new GridStoreAdapter('mongodb://localhost:27017/parse'); | ||
FCTestFactory.testAdapter("GridStoreAdapter", gridStoreAdapter); | ||
|
||
if (process.env.S3_ACCESS_KEY && process.env.S3_SECRET_KEY) { | ||
|
||
// Test the S3 Adapter | ||
var s3Adapter = new S3Adapter(process.env.S3_ACCESS_KEY, process.env.S3_SECRET_KEY, 'parse.server.tests'); | ||
|
||
FCTestFactory.testAdapter("S3Adapter",s3Adapter); | ||
|
||
// Test S3 with direct access | ||
var s3DirectAccessAdapter = new S3Adapter(process.env.S3_ACCESS_KEY, process.env.S3_SECRET_KEY, 'parse.server.tests', { | ||
directAccess: true | ||
}); | ||
|
||
FCTestFactory.testAdapter("S3AdapterDirect", s3DirectAccessAdapter); | ||
|
||
} else if (!process.env.TRAVIS) { | ||
console.log("set S3_ACCESS_KEY and S3_SECRET_KEY to test S3Adapter") | ||
} | ||
|
||
if (process.env.GCP_PROJECT_ID && process.env.GCP_KEYFILE_PATH && process.env.GCS_BUCKET) { | ||
|
||
// Test the GCS Adapter | ||
var gcsAdapter = new GCSAdapter(process.env.GCP_PROJECT_ID, process.env.GCP_KEYFILE_PATH, process.env.GCS_BUCKET); | ||
|
||
FCTestFactory.testAdapter("GCSAdapter", gcsAdapter); | ||
describe("FilesController",() =>{ | ||
it("should properly expand objects", (done) => { | ||
|
||
// Test GCS with direct access | ||
var gcsDirectAccessAdapter = new GCSAdapter(process.env.GCP_PROJECT_ID, process.env.GCP_KEYFILE_PATH, process.env.GCS_BUCKET, { | ||
directAccess: true | ||
}); | ||
var config = new Config(Parse.applicationId); | ||
var gridStoreAdapter = new GridStoreAdapter('mongodb://localhost:27017/parse'); | ||
let filesController = new FilesController(gridStoreAdapter) | ||
var result = filesController.expandFilesInObject(config, function(){}); | ||
|
||
FCTestFactory.testAdapter("GCSAdapterDirect", gcsDirectAccessAdapter); | ||
expect(result).toBeUndefined(); | ||
|
||
} else if (!process.env.TRAVIS) { | ||
console.log("set GCP_PROJECT_ID, GCP_KEYFILE_PATH, and GCS_BUCKET to test GCSAdapter") | ||
} | ||
var fullFile = { | ||
type: '__type', | ||
url: "http://an.url" | ||
} | ||
|
||
try { | ||
// Test the file system adapter | ||
var fsAdapter = new FileSystemAdapter({ | ||
filesSubDirectory: 'sub1/sub2' | ||
}); | ||
var anObject = { | ||
aFile: fullFile | ||
} | ||
filesController.expandFilesInObject(config, anObject); | ||
expect(anObject.aFile.url).toEqual("http://an.url"); | ||
|
||
FCTestFactory.testAdapter("FileSystemAdapter", fsAdapter); | ||
} catch (e) { | ||
console.log("Give write access to the file system to test the FileSystemAdapter. Error: " + e); | ||
} | ||
done(); | ||
}) | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.