-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b3ac69
commit c012a99
Showing
4 changed files
with
353 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/** | ||
* Copyright (c) 2017, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
/** | ||
* tests/api/v1/redisEnabled/redisTestUtil.js | ||
*/ | ||
'use strict'; // eslint-disable-line strict | ||
const sampleStore = require('../../../../cache/sampleStore'); | ||
const redisClient = require('../../../../cache/redisCache').client.sampleStore; | ||
const tu = require('../../../testUtils'); | ||
const Aspect = tu.db.Aspect; | ||
const Subject = tu.db.Subject; | ||
const Sample = tu.db.Sample; | ||
const testStartTime = new Date(); | ||
|
||
module.exports = { | ||
populateRedis(done) { | ||
let a1; | ||
let a2; | ||
let s1; | ||
let s2; | ||
let s3; | ||
tu.toggleOverride(sampleStore.constants.featureName, true); | ||
Aspect.create({ | ||
isPublished: true, | ||
name: `${tu.namePrefix}Aspect1`, | ||
timeout: '30s', | ||
valueType: 'NUMERIC', | ||
criticalRange: [0, 1], | ||
relatedLinks: [ | ||
{ name: 'Google', value: 'http://www.google.com' }, | ||
{ name: 'Yahoo', value: 'http://www.yahoo.com' }, | ||
], | ||
}) | ||
.then((created) => (a1 = created)) | ||
.then(() => Aspect.create({ | ||
isPublished: true, | ||
name: `${tu.namePrefix}Aspect2`, | ||
timeout: '10m', | ||
valueType: 'BOOLEAN', | ||
okRange: [10, 100], | ||
})) | ||
.then((created) => (a2 = created)) | ||
.then(() => Subject.create({ | ||
isPublished: true, | ||
name: `${tu.namePrefix}Subject1`, | ||
})) | ||
.then((created) => (s1 = created)) | ||
.then(() => Subject.create({ | ||
isPublished: true, | ||
name: `${tu.namePrefix}Subject2`, | ||
parentId: s1.id, | ||
})) | ||
.then((created) => (s2 = created)) | ||
.then(() => Subject.create({ | ||
isPublished: true, | ||
name: `${tu.namePrefix}Subject3`, | ||
parentId: s1.id, | ||
})) | ||
.then((created) => (s3 = created)) | ||
.then(() => Sample.create({ | ||
subjectId: s2.id, | ||
aspectId: a1.id, | ||
value: '0', | ||
relatedLinks: [ | ||
{ name: 'Salesforce', value: 'http://www.salesforce.com' }, | ||
], | ||
})) | ||
.then(() => Sample.create({ | ||
subjectId: s2.id, | ||
aspectId: a2.id, | ||
value: '50', | ||
relatedLinks: [ | ||
{ name: 'Salesforce', value: 'http://www.salesforce.com' }, | ||
], | ||
})) | ||
.then(() => Sample.create({ | ||
subjectId: s3.id, | ||
aspectId: a1.id, | ||
value: '5', | ||
relatedLinks: [ | ||
{ name: 'Salesforce', value: 'http://www.salesforce.com' }, | ||
], | ||
})) | ||
.then(() => sampleStore.init()) | ||
.then(() => done()) | ||
.catch(done); | ||
}, | ||
|
||
forceDelete: (done) => { | ||
tu.forceDelete(tu.db.Sample, testStartTime) | ||
.then(() => tu.forceDelete(tu.db.Aspect, testStartTime)) | ||
.then(() => tu.forceDelete(tu.db.Subject, testStartTime)) | ||
.then(() => tu.forceDelete(tu.db.Profile, testStartTime)) | ||
.then(() => tu.forceDelete(tu.db.User, testStartTime)) | ||
.then(() => redisClient.flushallAsync()) | ||
.then(() => done()) | ||
.catch(done); | ||
}, | ||
}; |
Oops, something went wrong.