-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { NotFoundError } from '@apextoaster/js-utils'; | ||
import { expect } from 'chai'; | ||
|
||
import { EntityModule } from '../../src/module/EntityModule'; | ||
import { MigrationModule } from '../../src/module/MigrationModule'; | ||
import { Storage } from '../../src/storage'; | ||
import { createServiceContainer } from '../helpers/container'; | ||
|
||
const TEST_METADATA = { | ||
kind: 'test-storage', | ||
name: 'test-storage', | ||
}; | ||
|
||
describe('storage service', async () => { | ||
xit('should handle connection errors'); | ||
|
||
it('should close connections when stopped', async () => { | ||
const { container } = await createServiceContainer(new EntityModule(), new MigrationModule()); | ||
const storage = await container.create(Storage, { | ||
data: { | ||
migrate: false, | ||
orm: { | ||
database: 'out/test.db', | ||
type: 'sqlite', | ||
}, | ||
}, | ||
metadata: TEST_METADATA, | ||
}); | ||
await storage.start(); | ||
await storage.stop(); | ||
expect(storage.isConnected).to.equal(false); | ||
}); | ||
|
||
it('should check connection status', async () => { | ||
const { container } = await createServiceContainer(new EntityModule(), new MigrationModule()); | ||
const storage = await container.create(Storage, { | ||
data: { | ||
migrate: false, | ||
orm: { | ||
database: 'test.db', | ||
type: 'sqlite', | ||
}, | ||
}, | ||
metadata: TEST_METADATA, | ||
}); | ||
await storage.start(); | ||
const connected = storage.isConnected; | ||
await storage.stop(); | ||
expect(connected).to.equal(true); | ||
}); | ||
}); |