mtcute/packages/sqlite/test/sqlite.test.ts

30 lines
1.1 KiB
TypeScript
Raw Normal View History

import { afterAll, beforeAll, describe } from 'vitest'
import { testAuthKeysRepository } from '@mtcute/core/src/storage/repository/auth-keys.test-utils.js'
import { testKeyValueRepository } from '@mtcute/core/src/storage/repository/key-value.test-utils.js'
import { testPeersRepository } from '@mtcute/core/src/storage/repository/peers.test-utils.js'
import { testRefMessagesRepository } from '@mtcute/core/src/storage/repository/ref-messages.test-utils.js'
import { LogManager } from '@mtcute/core/utils.js'
import { SqliteStorage } from '../src/index.js'
2023-11-29 20:31:18 +03:00
if (import.meta.env.TEST_ENV === 'node') {
describe('SqliteStorage', () => {
const storage = new SqliteStorage(':memory:')
2023-11-29 20:31:18 +03:00
beforeAll(() => {
storage.driver.setup(new LogManager())
storage.driver.load()
})
2023-11-29 20:31:18 +03:00
testAuthKeysRepository(storage.authKeys)
testKeyValueRepository(storage.kv, storage.driver)
testPeersRepository(storage.peers, storage.driver)
testRefMessagesRepository(storage.refMessages, storage.driver)
2023-11-29 20:31:18 +03:00
afterAll(() => storage.driver.destroy())
})
2023-11-29 20:31:18 +03:00
} else {
describe.skip('SqliteStorage', () => {})
}