forked from laurent22/joplin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Add tests for storage driver loading
- Loading branch information
Showing
4 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/server/src/models/items/storage/loadStorageDriver.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { afterAllTests, beforeAllDb, beforeEachDb, db, expectThrow, models } from '../../../utils/testing/testUtils'; | ||
import { StorageDriverType } from '../../../utils/types'; | ||
import loadStorageDriver from './loadStorageDriver'; | ||
|
||
describe('loadStorageDriver', function() { | ||
|
||
beforeAll(async () => { | ||
await beforeAllDb('loadStorageDriver'); | ||
}); | ||
|
||
afterAll(async () => { | ||
await afterAllTests(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await beforeEachDb(); | ||
}); | ||
|
||
test('should load a driver and assign an ID to it', async function() { | ||
{ | ||
const newDriver = await loadStorageDriver({ type: StorageDriverType.Memory }, db()); | ||
expect(newDriver.storageId).toBe(1); | ||
expect((await models().storage().count())).toBe(1); | ||
} | ||
|
||
{ | ||
const newDriver = await loadStorageDriver({ type: StorageDriverType.Filesystem, path: '/just/testing' }, db()); | ||
expect(newDriver.storageId).toBe(2); | ||
expect((await models().storage().count())).toBe(2); | ||
} | ||
}); | ||
|
||
test('should not record the same storage connection twice', async function() { | ||
await db()('storages').insert({ | ||
connection_string: 'Type=Database', | ||
updated_time: Date.now(), | ||
created_time: Date.now(), | ||
}); | ||
|
||
await expectThrow(async () => | ||
await db()('storages').insert({ | ||
connection_string: 'Type=Database', | ||
updated_time: Date.now(), | ||
created_time: Date.now(), | ||
}) | ||
); | ||
}); | ||
|
||
}); | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters