From e837197753930020276e4519133af75cbffcb6d3 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Sun, 14 Jan 2024 16:43:52 +0100 Subject: [PATCH] fix(git tests): Reset server repository manually Signed-off-by: Marcel Klehr --- src/lib/adapters/Git.ts | 15 +++++++++++++++ src/test/test.js | 33 +++++++++++++++++---------------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/lib/adapters/Git.ts b/src/lib/adapters/Git.ts index 5c7f058218..8890806154 100644 --- a/src/lib/adapters/Git.ts +++ b/src/lib/adapters/Git.ts @@ -346,6 +346,21 @@ export default class GitAdapter extends CachingAdapter { force: true, onAuth: () => this.onAuth() }) + await git.fetch({ + http, + fs, + dir: this.dir, + tags: true, + pruneTags: true, + remote: 'origin', + depth: 10, + onAuth: () => this.onAuth() + }) + const tags = await git.listTags({ fs, dir: this.dir }) + const lockTags = tags.filter(tag => tag.startsWith('floccus-lock-')) + for (const tag of lockTags) { + await git.push({ fs, http, dir: this.dir, ref: tag, delete: true, onAuth: () => this.onAuth() }) + } } } diff --git a/src/test/test.js b/src/test/test.js index 2f715b7ccc..643b7ec0e4 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -258,7 +258,11 @@ describe('Floccus', function() { } catch (e) { console.error(e) } - if (ACCOUNT_DATA.type !== 'fake') { + if (ACCOUNT_DATA.type === 'git') { + await account.server.clearServer() + GitAdapter.resetFilesystem() + } + else if (ACCOUNT_DATA.type !== 'fake') { await account.setData({ ...account.getData(), serverRoot: null }) const tree = await getAllBookmarks(account) await withSyncConnection(account, async() => { @@ -278,9 +282,6 @@ describe('Floccus', function() { await account.server.deleteFile(file.id) } } - if (ACCOUNT_DATA.type === 'git') { - GitAdapter.resetFilesystem() - } await account.delete() }) it('should create local bookmarks on the server', async function() { @@ -3162,7 +3163,10 @@ describe('Floccus', function() { }) afterEach('clean up accounts', async function() { await browser.bookmarks.removeTree(account1.getData().localRoot) - if (ACCOUNT_DATA.type !== 'fake') { + if (ACCOUNT_DATA.type === 'git') { + await account1.server.clearServer() + GitAdapter.resetFilesystem() + }else if (ACCOUNT_DATA.type !== 'fake') { await account1.setData({ ...account1.getData(), serverRoot: null @@ -3185,9 +3189,6 @@ describe('Floccus', function() { await account1.server.deleteFile(file.id) } } - if (ACCOUNT_DATA.type === 'git') { - GitAdapter.resetFilesystem() - } await account1.delete() await browser.bookmarks.removeTree(account2.getData().localRoot) await account2.delete() @@ -4556,7 +4557,10 @@ describe('Floccus', function() { } catch (e) { console.error(e) } - if (ACCOUNT_DATA.type !== 'fake') { + if (ACCOUNT_DATA.type === 'git') { + await account.server.clearServer() + GitAdapter.resetFilesystem() + }else if (ACCOUNT_DATA.type !== 'fake') { await account.setData({ ...account.getData(), serverRoot: null }) const tree = await getAllBookmarks(account) await withSyncConnection(account, async() => { @@ -4576,9 +4580,6 @@ describe('Floccus', function() { await account.server.deleteFile(file.id) } } - if (ACCOUNT_DATA.type === 'git') { - GitAdapter.resetFilesystem() - } await account.delete() }) it('should create local tabs on the server', async function() { @@ -4876,7 +4877,10 @@ describe('Floccus', function() { afterEach('clean up accounts', async function() { RUN_INTERRUPTS = false await browser.bookmarks.removeTree(account1.getData().localRoot) - if (ACCOUNT_DATA.type !== 'fake') { + if (ACCOUNT_DATA.type === 'git') { + await account1.server.clearServer() + GitAdapter.resetFilesystem() + } else if (ACCOUNT_DATA.type !== 'fake') { await account1.setData({ ...account1.getData(), serverRoot: null @@ -4899,9 +4903,6 @@ describe('Floccus', function() { await account1.server.deleteFile(file.id) } } - if (ACCOUNT_DATA.type === 'git') { - GitAdapter.resetFilesystem() - } await account1.delete() await browser.bookmarks.removeTree(account2.getData().localRoot) await account2.delete()