Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions .claude/skills/testing/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
name: testing
description: Run and troubleshoot tests for DBHub, including unit tests, integration tests with Testcontainers, and database-specific tests. Use when asked to run tests, fix test failures, debug integration tests, or troubleshoot Docker/database container issues.
---

# Testing Skill

This skill helps you run and troubleshoot tests in the DBHub project.

## Quick Commands

Before running tests, consult [TESTING.md](../../../TESTING.md) for comprehensive documentation.

Copilot AI Nov 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The referenced file TESTING.md does not exist in the repository. This broken link will prevent users from accessing the comprehensive testing documentation mentioned here. Either add the missing TESTING.md file or update the reference.

Copilot uses AI. Check for mistakes.

Common test commands:
- `pnpm test` - Run all tests
- `pnpm test:watch` - Run tests in watch mode
- `pnpm test:integration` - Run integration tests (requires Docker)
- `pnpm test src/connectors/__tests__/{db-type}.integration.test.ts` - Test specific database connector

## Integration Testing

Integration tests use [Testcontainers](https://testcontainers.com/) to run real database instances in Docker.

### Prerequisites Checklist

Before running integration tests, verify:
1. Docker is installed and running: `docker ps`
2. Sufficient Docker memory allocated (4GB+ recommended)
3. Network access to pull Docker images

### Database-Specific Tests

Test individual database connectors:
```bash
# PostgreSQL
pnpm test src/connectors/__tests__/postgres.integration.test.ts

# MySQL
pnpm test src/connectors/__tests__/mysql.integration.test.ts

# MariaDB
pnpm test src/connectors/__tests__/mariadb.integration.test.ts

# SQL Server
pnpm test src/connectors/__tests__/sqlserver.integration.test.ts

# SQLite
pnpm test src/connectors/__tests__/sqlite.integration.test.ts

# JSON RPC integration
pnpm test src/__tests__/json-rpc-integration.test.ts
```

## Troubleshooting

### Container Startup Issues

If containers fail to start:
```bash
# Verify Docker is running
docker ps

# Check disk space
docker system df

# Manually pull images
docker pull postgres:15-alpine
docker pull mysql:8.0
docker pull mariadb:10.11
docker pull mcr.microsoft.com/mssql/server:2019-latest
```

### SQL Server Timeout Issues

SQL Server containers require 3-5 minutes to start:
- Ensure Docker has 4GB+ memory allocated
- Run SQL Server tests separately: `pnpm test src/connectors/__tests__/sqlserver.integration.test.ts`
- Check timeout settings in test files

### Debug Failed Tests

```bash
# Run with verbose output
pnpm test:integration --reporter=verbose

# Run specific test pattern
pnpm test:integration -- --testNamePattern="PostgreSQL"

# Check container logs
docker logs <container_id>
```

## Test Architecture

All integration tests follow this pattern:
1. **Container Lifecycle**: Start database container → Connect → Setup test data → Run tests → Cleanup
2. **Shared Test Utilities**: Common patterns in `IntegrationTestBase` class
3. **Database-Specific Features**: Each database tests unique capabilities
4. **Error Handling**: Comprehensive testing of connection errors, invalid SQL, edge cases

## When to Use This Skill

Use this skill when:
- Asked to run tests or verify code changes
- Debugging test failures
- Setting up integration tests for new features
- Troubleshooting Docker or Testcontainers issues
- Adding new database connector tests
- Investigating CI/CD test failures

## Related Files

- [TESTING.md](../../../TESTING.md) - Comprehensive testing documentation

Copilot AI Nov 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The referenced file TESTING.md does not exist in the repository. This broken link in the "Related Files" section will result in a 404 error. Either add the missing file or update the reference.

Copilot uses AI. Check for mistakes.
- `src/connectors/__tests__/` - Integration test files
- `vitest.config.ts` - Vitest configuration
- `.github/workflows/` - CI/CD test workflows
5 changes: 5 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ DBHub supports three configuration methods (in priority order):

## Testing Approach

See [TESTING.md](TESTING.md) for comprehensive testing documentation.

Copilot AI Nov 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The referenced file TESTING.md does not exist in the repository. This broken link will prevent developers from accessing the testing documentation. Either add the missing file or update the reference to point to an existing documentation location.

Suggested change
See [TESTING.md](TESTING.md) for comprehensive testing documentation.
See [testing skill](.claude/skills/testing/SKILL.md) for comprehensive testing documentation.

Copilot uses AI. Check for mistakes.

For detailed guidance on running and troubleshooting tests, refer to the [testing skill](.claude/skills/testing/SKILL.md). This skill is automatically activated when working with tests, test failures, or Docker/database container issues.

Key points:
- Unit tests for individual components and utilities
- Integration tests using Testcontainers for real database testing
- All connectors have comprehensive integration test coverage
Expand Down
87 changes: 4 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,89 +105,10 @@ See [Multi-Database Configuration](https://dbhub.ai/config/multi-database) for c

### Testing

The project uses Vitest for comprehensive unit and integration testing:

- **Run all tests**: `pnpm test`
- **Run tests in watch mode**: `pnpm test:watch`
- **Run integration tests**: `pnpm test:integration`

#### Integration Tests

DBHub includes comprehensive integration tests for all supported database connectors using [Testcontainers](https://testcontainers.com/). These tests run against real database instances in Docker containers, ensuring full compatibility and feature coverage.

##### Prerequisites

- **Docker**: Ensure Docker is installed and running on your machine
- **Docker Resources**: Allocate sufficient memory (recommended: 4GB+) for multiple database containers
- **Network Access**: Ability to pull Docker images from registries

##### Running Integration Tests

**Note**: This command runs all integration tests in parallel, which may take 5-15 minutes depending on your system resources and network speed.

```bash
# Run all database integration tests
pnpm test:integration
```

```bash
# Run only PostgreSQL integration tests
pnpm test src/connectors/__tests__/postgres.integration.test.ts
# Run only MySQL integration tests
pnpm test src/connectors/__tests__/mysql.integration.test.ts
# Run only MariaDB integration tests
pnpm test src/connectors/__tests__/mariadb.integration.test.ts
# Run only SQL Server integration tests
pnpm test src/connectors/__tests__/sqlserver.integration.test.ts
# Run only SQLite integration tests
pnpm test src/connectors/__tests__/sqlite.integration.test.ts
# Run JSON RPC integration tests
pnpm test src/__tests__/json-rpc-integration.test.ts
```

All integration tests follow these patterns:

1. **Container Lifecycle**: Start database container → Connect → Setup test data → Run tests → Cleanup
2. **Shared Test Utilities**: Common test patterns implemented in `IntegrationTestBase` class
3. **Database-Specific Features**: Each database includes tests for unique features and capabilities
4. **Error Handling**: Comprehensive testing of connection errors, invalid SQL, and edge cases

##### Troubleshooting Integration Tests

**Container Startup Issues:**

```bash
# Check Docker is running
docker ps

# Check available memory
docker system df

# Pull images manually if needed
docker pull postgres:15-alpine
docker pull mysql:8.0
docker pull mariadb:10.11
docker pull mcr.microsoft.com/mssql/server:2019-latest
```

**SQL Server Timeout Issues:**

- SQL Server containers require significant startup time (3-5 minutes)
- Ensure Docker has sufficient memory allocated (4GB+ recommended)
- Consider running SQL Server tests separately if experiencing timeouts

**Network/Resource Issues:**

```bash
# Run tests with verbose output
pnpm test:integration --reporter=verbose

# Run single database test to isolate issues
pnpm test:integration -- --testNamePattern="PostgreSQL"

# Check Docker container logs if tests fail
docker logs <container_id>
```
See [TESTING.md](TESTING.md) for comprehensive testing documentation, including:

Copilot AI Nov 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The referenced file TESTING.md does not exist in the repository. This broken link will prevent users from accessing the testing documentation that was removed from this file. Either:

  1. Add the TESTING.md file with the appropriate testing documentation, or
  2. Update the reference to point to an existing file or documentation location
Suggested change
See [TESTING.md](TESTING.md) for comprehensive testing documentation, including:
Comprehensive testing documentation is coming soon. For now, please refer to the following:

Copilot uses AI. Check for mistakes.
- Test commands and workflows
- Integration testing with Docker/Testcontainers
- Prerequisites and troubleshooting guides

### Debug with [MCP Inspector](https://github.com/modelcontextprotocol/inspector)

Expand Down