feat: implement database service with SQL Server and MySQL support
- Add database types (QueryResult, TransactionResult) - Implement DatabaseService with connection management for SQL Server and MySQL - Add query execution methods for both database types - Include comprehensive error handling and logging - Add unit test for error handling - Configure Jest for testing Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
26
tests/unit/services/database.service.test.ts
Normal file
26
tests/unit/services/database.service.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { DatabaseService } from '../../../src/main/services/database.service';
|
||||
|
||||
describe('DatabaseService', () => {
|
||||
it('should throw error when querying without connection', async () => {
|
||||
const service = new DatabaseService(
|
||||
{
|
||||
server: 'localhost',
|
||||
database: 'test',
|
||||
username: 'test',
|
||||
password: 'test',
|
||||
driver: 'test',
|
||||
},
|
||||
{
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
database: 'test',
|
||||
username: 'test',
|
||||
password: 'test',
|
||||
}
|
||||
);
|
||||
|
||||
await expect(
|
||||
service.executeSQLServerQuery('SELECT 1')
|
||||
).rejects.toThrow('SQL Server not connected');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user