From 4f5e7367d0235cecd980523d7dea9946b8864855 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 27 Mar 2018 17:48:55 +0100 Subject: [PATCH] Minor tweals --- CliClient/tests/synchronizer.js | 14 +++++++------- CliClient/tests/test-utils.js | 9 +++++---- ReactNativeClient/lib/shim.js | 3 +++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CliClient/tests/synchronizer.js b/CliClient/tests/synchronizer.js index dbdaf799e..4ef35e86d 100644 --- a/CliClient/tests/synchronizer.js +++ b/CliClient/tests/synchronizer.js @@ -372,7 +372,7 @@ describe('Synchronizer', function() { expect(items.length).toBe(1); expect(items[0].title).toBe('note1'); expect(items[0].is_conflict).toBe(1); - })); + })); it('should resolve conflict if note has been deleted remotely and locally', asyncTest(async () => { let folder = await Folder.save({ title: "folder" }); @@ -542,11 +542,11 @@ describe('Synchronizer', function() { let n1 = await Note.save({ title: "mynote" }); let n2 = await Note.save({ title: "mynote2" }); let tag = await Tag.save({ title: 'mytag' }); - await synchronizer().start(); + let context1 = await synchronizer().start(); await switchClient(2); - await synchronizer().start(); + let context2 = await synchronizer().start(); if (withEncryption) { const masterKey_2 = await MasterKey.load(masterKey.id); await encryptionService().loadMasterKey(masterKey_2, '123456', true); @@ -560,21 +560,21 @@ describe('Synchronizer', function() { await Tag.addNote(remoteTag.id, n2.id); let noteIds = await Tag.noteIds(tag.id); expect(noteIds.length).toBe(2); - await synchronizer().start(); + context2 = await synchronizer().start({ context: context2 }); await switchClient(1); - await synchronizer().start(); + context1 = await synchronizer().start({ context: context1 }); let remoteNoteIds = await Tag.noteIds(tag.id); expect(remoteNoteIds.length).toBe(2); await Tag.removeNote(tag.id, n1.id); remoteNoteIds = await Tag.noteIds(tag.id); expect(remoteNoteIds.length).toBe(1); - await synchronizer().start(); + context1 = await synchronizer().start({ context: context1 }); await switchClient(2); - await synchronizer().start(); + context2 = await synchronizer().start({ context: context2 }); noteIds = await Tag.noteIds(tag.id); expect(noteIds.length).toBe(1); expect(remoteNoteIds[0]).toBe(noteIds[0]); diff --git a/CliClient/tests/test-utils.js b/CliClient/tests/test-utils.js index 0dc7bf165..394f83cc5 100644 --- a/CliClient/tests/test-utils.js +++ b/CliClient/tests/test-utils.js @@ -57,9 +57,9 @@ SyncTargetRegistry.addClass(SyncTargetNextcloud); SyncTargetRegistry.addClass(SyncTargetDropbox); // const syncTargetId_ = SyncTargetRegistry.nameToId("nextcloud"); -// const syncTargetId_ = SyncTargetRegistry.nameToId("memory"); +const syncTargetId_ = SyncTargetRegistry.nameToId("memory"); //const syncTargetId_ = SyncTargetRegistry.nameToId('filesystem'); -const syncTargetId_ = SyncTargetRegistry.nameToId('dropbox'); +// const syncTargetId_ = SyncTargetRegistry.nameToId('dropbox'); const syncDir = __dirname + '/../tests/sync'; const sleepTime = syncTargetId_ == SyncTargetRegistry.nameToId('filesystem') ? 1001 : 100;//400; @@ -256,7 +256,7 @@ function fileApi() { const api = new DropboxApi(); const authTokenPath = __dirname + '/support/dropbox-auth.txt'; const authToken = fs.readFileSync(authTokenPath, 'utf8'); - if (!authTokenPath) throw new Error('Dropbox auth token missing in ' + authTokenPath); + if (!authToken) throw new Error('Dropbox auth token missing in ' + authTokenPath); api.setAuthToken(authToken); fileApi_ = new FileApi('', new FileApiDriverDropbox(api)); } @@ -301,8 +301,9 @@ function asyncTest(callback) { await callback(); } catch (error) { console.error(error); + } finally { + done(); } - done(); } } diff --git a/ReactNativeClient/lib/shim.js b/ReactNativeClient/lib/shim.js index 4c7d5d5c7..0d1fa088e 100644 --- a/ReactNativeClient/lib/shim.js +++ b/ReactNativeClient/lib/shim.js @@ -85,6 +85,9 @@ shim.fetchRequestCanBeRetried = function(error) { // Code: ETIMEDOUT if (error.code === 'ETIMEDOUT') return true; + // ECONNREFUSED is generally temporary + if (error.code === 'ECONNREFUSED') return true; + return false; };