fix-bug
Use when given a GitHub issue URL or number to investigate and implement a fix. Triggers on "fix issue", "fix bug", "fix #123", GitHub issue URLs, or any…
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, troubleshoot Docker/database container issues, or add new tests. Also use when
$ npx -y skills add bytebase/dbhub --skill testing --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/testingContext preview
The summary Claude sees to decide when to auto-load this skill.
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, troubleshoot Docker/database container issues, or add new tests. Also use when
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, troubleshoot Docker/database container issues, or add new tests. Also use when verifying code changes work correctly or when CI test failures need investigation.
This skill helps you run, write, and troubleshoot tests in the DBHub project.
pnpm test # Run all tests (unit + integration) pnpm test:unit # Unit tests only (no Docker needed) pnpm test:watch # Interactive watch mode pnpm test:integration # Integration tests only (requires Docker)
Run a specific test file:
pnpm test src/connectors/__tests__/postgres.integration.test.ts pnpm test src/utils/__tests__/allowed-keywords.test.ts
Run tests matching a name pattern:
pnpm test -- --testNamePattern="PostgreSQL"
Verbose output for debugging:
pnpm test:integration --reporter=verbose
Vitest is configured with two projects in `vitest.config.ts`:
This means the naming convention matters — integration tests MUST have `integration` in their filename to be correctly categorized.
**Unit tests** (~20 files, no Docker needed):
**Integration tests** (~11 files, Docker required):
Database connector integration tests extend `IntegrationTestBase<TContainer>` from `src/connectors/__tests__/shared/integration-test-base.ts`. This abstract class provides:
To add a new database connector test, extend this class and implement:
Located in `src/__fixtures__/`:
Usage:
import { setupManagerWithFixture, FIXTURES } from '../../__fixtures__/helpers.js';
const manager = await setupManagerWithFixture(FIXTURES.MULTI_SQLITE);
// ... test ...
await manager.disconnect();Unit tests use vitest mocking:
vi.mock('../../connectors/manager.js'); // Mock ConnectorManager
vi.mocked(ConnectorManager.getCurrentConnector).mockReturnValue(mockConnector);SSH tunnel tests mock `SSHTunnel.prototype.establish` to avoid real SSH connections while testing config passing.
Integration tests use [Testcontainers](https://testcontainers.com/) to run real database instances in Docker.
Before running integration tests: 1. Docker is installed and running: `docker ps` 2. Sufficient Docker memory (4GB+ recommended, especially for SQL Server) 3. Network access to pull Docker images
| Database | Image | Notes | |----------|-------|-------| | PostgreSQL | `postgres:15-alpine` | Fast startup | | MySQL | `@testcontainers/mysql` | Supports IAM auth testing | | MariaDB | `@testcontainers/mariadb` | Supports IAM auth testing | | SQL Server | `@testcontainers/mssqlserver` | Slow startup (3-5 min), needs 4GB+ RAM | | SQLite | No container needed | In-memory or file-based |
docker ps # Verify Docker is running docker system df # Check disk space docker pull postgres:15-alpine # Manually pull images
SQL Server containers are the slowest to start (3-5 minutes). Run them separately and ensure Docker has 4GB+ memory:
pnpm test src/connectors/__tests__/sqlserver.integration.test.ts
Each integration test manages its own container lifecycle. If containers leak, clean up:
docker ps -a | grep testcontainers # Find leaked containers docker container prune # Clean up stopped containers
The CI workflow (`.github/workflows/ru
Token conscious database MCP server for Postgres, MySQL, SQL Server, MariaDB, SQLite.
Repo: bytebase/dbhub
Use when given a GitHub issue URL or number to investigate and implement a fix. Triggers on "fix issue", "fix bug", "fix #123", GitHub issue URLs, or any…
Explore a database schema token-efficiently via the DBHub tools; use before writing SQL against a schema you haven't seen.
Connect DBHub to a database or fix a failing connection; also covers changing the DSN, write access, or multiple databases.
Guide for querying databases through DBHub MCP server. Use this skill whenever you need to explore database schemas, inspect tables, or run SQL queries via…