Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

previousFetchTime parameter for FETCH_SYNC_RECORDS #363

Merged
merged 3 commits into from Jan 10, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Tests for RequestUtil.shouldListObject and other tests updated to use…

… previousFetchTime
  • Loading branch information
AlexeyBarabash committed Dec 27, 2019
commit 9c3c937aef9dbf596dbd8500dbf754cdbb34b82b
@@ -97,7 +97,7 @@ test('deviceId V2 migration', (t) => {
const testCanListFromOldQueue = (t) => {
t.test('can list notification from old SQS queue', (t) => {
let currentTime = new Date().getTime()
requestUtil.list(proto.categories.BOOKMARKS, currentTime)
requestUtil.list(proto.categories.BOOKMARKS, currentTime, 0, '', currentTime)
.then(s3Objects => requestUtil.s3ObjectsToRecords(s3Objects.contents))
.then((response) => {
t.equals(response.length, 1)
@@ -127,7 +127,7 @@ test('deviceId V2 migration', (t) => {
const testCanListFromBothQueues = (t) => {
t.test('can list notifications from new and old SQS queues', (t) => {
let currentTime = new Date().getTime()
requestUtil.list(proto.categories.BOOKMARKS, currentTime)
requestUtil.list(proto.categories.BOOKMARKS, currentTime, 0, '', currentTime)
.then(s3Objects => requestUtil.s3ObjectsToRecords(s3Objects.contents))
.then((response) => {
t.equals(response.length, 1)
@@ -52,7 +52,25 @@ test('client RequestUtil', (t) => {
})
const serializer = requestUtil.serializer

t.plan(2)
t.plan(3)

t.test('#should list object', (t) => {
t.plan(3)

t.equals(true,
requestUtil.shouldListObject(0, proto.categories.BOOKMARKS),
`${t.name}: previous fetch time is empty - use S3`)

t.equals(false,
requestUtil.shouldListObject(new Date().getTime()-1000*60, proto.categories.BOOKMARKS),
`${t.name}: previous fetch is not older than 24h - use SQS`)

const delta25hours = 1000*60*60*25
t.equals(true,
requestUtil.shouldListObject(new Date().getTime()-delta25hours, proto.categories.BOOKMARKS),
`${t.name}: previous fetch is older than 24h - use S3`)
})

t.test('#put preference: device', (t) => {
t.plan(2)
const deviceId = new Uint8Array([0])
@@ -288,7 +306,7 @@ test('client RequestUtil', (t) => {
const testCanListNotifications = (t) => {
t.test(`${t.name} can list notification`, (t) => {
let currentTime = new Date().getTime()
requestUtil.list(proto.categories.BOOKMARKS, currentTime)
requestUtil.list(proto.categories.BOOKMARKS, currentTime, 1000, '', currentTime)
.then(s3Objects => requestUtil.s3ObjectsToRecords(s3Objects.contents))
.then((response) => {
const s3Record = response[1] ? response[1].record : response[1]
@@ -461,7 +479,7 @@ test('client RequestUtil', (t) => {
}
// limit batch size to 10 to test cross batch compaction for around 40
// objects
requestUtil.list(proto.categories.BOOKMARKS, 0, 10, '', {compaction: true,
requestUtil.list(proto.categories.BOOKMARKS, 0, 10, '', 0, {compaction: true,
compactionUpdateCb: compactionUpdate,
compactionDoneCb: () => {
console.log = consoleLogBak
@@ -474,7 +492,7 @@ test('client RequestUtil', (t) => {
compactedRecord.filter(record => record.objectId.toString() === record2_update.objectId.toString()).length, 5)
// we already have 15 second timeout for each batch so no need to
// do another wait after compaction is done
requestUtil.list(proto.categories.BOOKMARKS, 0, 0)
requestUtil.list(proto.categories.BOOKMARKS, 0, 0, '', 0)
.then(s3Objects => requestUtil.s3ObjectsToRecords(s3Objects.contents))
.then((response) => {
t.equals(response.length, 2, `${t.name} check records number`)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.