forked from parse-community/parse-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
* upstream/master: (63 commits) Fixes parse-community#1649 (parse-community#1650) Update issue template (parse-community#1899) Break schemaController dependency. (parse-community#1901) Remove unnecessary null check Update schema mismatch error to include type string (parse-community#1898) Move more mongo specific stuff into mongo adapter Kill mongoOptions Consistent parameter order move transformWhere into mongo adapter Remove options from count Can't sort a count Remove limit from count Destructure mongo options remove adaptive collection call create + use adapter count instead of collection count transformWhere in MongoAdapter remove schemaController paramater Remove schemaController parameter Remove getRelationFields Remove all dependencies on schemaController ...
- Loading branch information
Showing
54 changed files
with
2,241 additions
and
1,191 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
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
var CacheController = require('../src/Controllers/CacheController.js').default; | ||
|
||
describe('CacheController', function() { | ||
var FakeCacheAdapter; | ||
var FakeAppID = 'foo'; | ||
var KEY = 'hello'; | ||
|
||
beforeEach(() => { | ||
FakeCacheAdapter = { | ||
get: () => Promise.resolve(null), | ||
put: jasmine.createSpy('put'), | ||
del: jasmine.createSpy('del'), | ||
clear: jasmine.createSpy('clear') | ||
} | ||
|
||
spyOn(FakeCacheAdapter, 'get').and.callThrough(); | ||
}); | ||
|
||
|
||
it('should expose role and user caches', (done) => { | ||
var cache = new CacheController(FakeCacheAdapter, FakeAppID); | ||
|
||
expect(cache.role).not.toEqual(null); | ||
expect(cache.role.get).not.toEqual(null); | ||
expect(cache.user).not.toEqual(null); | ||
expect(cache.user.get).not.toEqual(null); | ||
|
||
done(); | ||
}); | ||
|
||
|
||
['role', 'user'].forEach((cacheName) => { | ||
it('should prefix ' + cacheName + ' cache', () => { | ||
var cache = new CacheController(FakeCacheAdapter, FakeAppID)[cacheName]; | ||
|
||
cache.put(KEY, 'world'); | ||
var firstPut = FakeCacheAdapter.put.calls.first(); | ||
expect(firstPut.args[0]).toEqual([FakeAppID, cacheName, KEY].join(':')); | ||
|
||
cache.get(KEY); | ||
var firstGet = FakeCacheAdapter.get.calls.first(); | ||
expect(firstGet.args[0]).toEqual([FakeAppID, cacheName, KEY].join(':')); | ||
|
||
cache.del(KEY); | ||
var firstDel = FakeCacheAdapter.del.calls.first(); | ||
expect(firstDel.args[0]).toEqual([FakeAppID, cacheName, KEY].join(':')); | ||
}); | ||
}); | ||
|
||
it('should clear the entire cache', () => { | ||
var cache = new CacheController(FakeCacheAdapter, FakeAppID); | ||
|
||
cache.clear(); | ||
expect(FakeCacheAdapter.clear.calls.count()).toEqual(1); | ||
|
||
cache.user.clear(); | ||
expect(FakeCacheAdapter.clear.calls.count()).toEqual(2); | ||
|
||
cache.role.clear(); | ||
expect(FakeCacheAdapter.clear.calls.count()).toEqual(3); | ||
}); | ||
|
||
it('should handle cache rejections', (done) => { | ||
|
||
FakeCacheAdapter.get = () => Promise.reject(); | ||
|
||
var cache = new CacheController(FakeCacheAdapter, FakeAppID); | ||
|
||
cache.get('foo').then(done, () => { | ||
fail('Promise should not be rejected.'); | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.