Skip to content

Commit

Permalink
fix(tests): Clean up file system after each test
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Jan 14, 2024
1 parent d29a609 commit 0ccc2dc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/adapters/Git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Crypto from '../Crypto'

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const fs: FS = new FS('floccus', {wipe: true})
let fs: FS = new FS('floccus', {wipe: true})

const LOCK_INTERVAL = 2 * 60 * 1000 // Lock every 2mins while syncing
const LOCK_TIMEOUT = 15 * 60 * 1000 // Override lock 0.25h after last time lock has been set
Expand All @@ -30,6 +30,12 @@ export default class GitAdapter extends CachingAdapter {
private initialTreeHash: string
private dir: string

static resetFilesystem(): void {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
fs = new FS('floccus', {wipe: true})
}

constructor(server) {
super(server)
this.server = server
Expand Down
13 changes: 13 additions & 0 deletions src/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as AsyncParallel from 'async-parallel'
import DefunctCrypto from '../lib/DefunctCrypto'
import Controller from '../lib/Controller'
import FakeAdapter from '../lib/adapters/Fake'
import GitAdapter from '../lib/adapters/Git'

chai.use(chaiAsPromised)
const expect = chai.expect
Expand Down Expand Up @@ -277,6 +278,9 @@ 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 @@ -3181,6 +3185,9 @@ 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 @@ -4569,6 +4576,9 @@ 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 @@ -4889,6 +4899,9 @@ 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 0ccc2dc

Please sign in to comment.