Skip to content

Commit

Permalink
fix(git tests): Reset server repository manually
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr committed Jan 14, 2024
1 parent c0376e3 commit e837197
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
15 changes: 15 additions & 0 deletions src/lib/adapters/Git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() })
}
}
}

Expand Down
33 changes: 17 additions & 16 deletions src/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Check failure on line 264 in src/test/test.js

View workflow job for this annotation

GitHub Actions / js node20.x

Closing curly brace does not appear on the same line as the subsequent block

Check failure on line 264 in src/test/test.js

View workflow job for this annotation

GitHub Actions / init (20.x, 10.x)

Closing curly brace does not appear on the same line as the subsequent block
else if (ACCOUNT_DATA.type !== 'fake') {
await account.setData({ ...account.getData(), serverRoot: null })
const tree = await getAllBookmarks(account)
await withSyncConnection(account, async() => {
Expand All @@ -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() {
Expand Down Expand Up @@ -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') {

Check failure on line 3169 in src/test/test.js

View workflow job for this annotation

GitHub Actions / js node20.x

Expected space(s) before "else"

Check failure on line 3169 in src/test/test.js

View workflow job for this annotation

GitHub Actions / init (20.x, 10.x)

Expected space(s) before "else"
await account1.setData({
...account1.getData(),
serverRoot: null
Expand All @@ -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()
Expand Down Expand Up @@ -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') {

Check failure on line 4563 in src/test/test.js

View workflow job for this annotation

GitHub Actions / js node20.x

Expected space(s) before "else"

Check failure on line 4563 in src/test/test.js

View workflow job for this annotation

GitHub Actions / init (20.x, 10.x)

Expected space(s) before "else"
await account.setData({ ...account.getData(), serverRoot: null })
const tree = await getAllBookmarks(account)
await withSyncConnection(account, async() => {
Expand All @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit e837197

Please sign in to comment.