agentleFS
bytebasebytebase/dbhub/.claude/skills/testing/SKILL.md

testing

Skill3.6k starsChanged 2 months agoMITView on GitHub

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.

123 other projects use a version of this.

Trending

More talk lately.about the whole repository

Dec 2025: 2 mentionsJan 2026: 2 mentionsFeb 2026: 1 mentionMar 2026: 1 mentionApr 2026: 1 mentionMay 2026: 0 mentionsJun 2026: 1 mentionJul 2026: 2 mentionsAug 2026: 1 mentionSep 2026: 3 mentionsOct 2026: 2 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the bytebase/dbhub repository that our weekly crawl found. There is no adoption data for this file yet.

Most recently taken up by

Who's talking about bytebase/dbhub

The biggest 5 of 22 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 22

Talked about on GitHub and Bluesky (22 times).

On GitHub · 21

16 more on GitHub

Used with

Projects with it also use oss-pr, pr-automation and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • CES-LtdSkill

    oss-pr

    Use when creating a pull request, after committing changes, or when user invokes /oss-pr. Covers branch management, quality checks, commit, push, and PR creation.

    Also in 3 projects that use this

  • CES-LtdSkill

    pr-automation

    PR Automation Orchestrator: poll open PRs, check CI, run review, fix, and merge eligible PRs. Use when: (1) Invoked by daemon via scripts/pr-automation.sh, (2) User says "/pr-automation".

    Also in 3 projects that use this

  • ffsshhttiikkSkill

    cicd

    Continuous integration and delivery pipelines

    Also in 4 projects that use this

  • ffsshhttiikkSkill

    networking

    Practical application and coding skills for Networking

    Also in 3 projects that use this

  • JohnJBorenSkill

    ci-cd

    CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies

    Also in 9 projects that use this

  • Cogni-AI-OUSkill

    dotfiles

    Reference for repository dotfiles, including their purposes, standard configurations, and usage guidelines. You MUST load this skill when configuring, troubleshooting, or understanding repository dotfiles.

    Also in 3 projects that use this

  • +2 more from CES-Ltd
  • +1 more from ffsshhttiikk

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 105 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run a specific test file:

    line 19
  2. Distinctive:

    Run tests matching a name pattern:

    line 25
  3. Very specific:

    integration: Only *integration*.test.ts files

    line 39
  4. Distinctive:

    Before running integration tests:

    line 110
  5. Very specific:

    Unit test: Create src/{module}/__tests__/{name}.test.ts — will auto-run with pnpm test:unit.

    line 153
  6. Very specific:

    Integration test: Create src/{module}/__tests__/{name}.integration.test.ts — the integration in the filename is what routes it to pnpm …

    line 155

“Common” is measured: kept by at least 6 in 10 of the 105 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Testing Skill

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

Test Commands

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

Test Architecture

Vitest is configured with two projects in vitest.config.ts:

  • unit: All *.test.ts files excluding *integration* in the filename
  • integration: Only *integration*.test.ts files

This means the naming convention matters — integration tests MUST have integration in their filename to be correctly categorized.

Test File Locations

Unit tests (~20 files, no Docker needed):

  • src/utils/__tests__/ — Utility function tests (SQL parsing, DSN obfuscation, SSH config, allowed keywords, identifier quoting, parameter mapping, row limiting, safe URL, config watcher, AWS RDS signer)
  • src/tools/__tests__/ — Tool handler tests (execute-sql, search-objects, custom-tool-handler)
  • src/config/__tests__/ — Configuration tests (env parsing, TOML loading)
  • src/connectors/__tests__/ — Connector unit tests (dsn-parser, manager)
  • src/requests/__tests__/ — Request store tests

Integration tests (~11 files, Docker required):

  • src/connectors/__tests__/postgres.integration.test.ts
  • src/connectors/__tests__/mysql.integration.test.ts
  • src/connectors/__tests__/mariadb.integration.test.ts
  • src/connectors/__tests__/sqlserver.integration.test.ts
  • src/connectors/__tests__/oracle.integration.test.ts
  • src/connectors/__tests__/sqlite.integration.test.ts
  • src/connectors/__tests__/postgres-ssh.integration.test.ts
  • src/connectors/__tests__/multi-sqlite-sources.integration.test.ts
  • src/__tests__/json-rpc-integration.test.ts
  • src/api/__tests__/sources.integration.test.ts
  • src/api/__tests__/requests.integration.test.ts
  • src/config/__tests__/ssh-config-integration.test.ts

IntegrationTestBase

Database connector integration tests extend IntegrationTestBase<TContainer> from src/connectors/__tests__/shared/integration-test-base.ts. This abstract class provides:

  • Lifecycle: Container start in beforeAll (120s timeout) → connect → setup test data → run tests → cleanup in afterAll
  • Shared test suites: createConnectionTests(), createSchemaTests(), createTableTests(), createSQLExecutionTests(), createStoredProcedureTests(), createCommentTests(), createErrorHandlingTests()
  • Standard test data: users table (id, name, email, age) + orders table (id, user_id, amount) + test_schema.products

To add a new database connector test, extend this class and implement:

  • createContainer() — Start the Testcontainers instance
  • createConnector() — Create the database connector
  • setupTestData(connector) — Populate test tables

Test Fixtures

Located in src/__fixtures__/:

  • helpers.ts — Utilities: fixtureTomlPath(), loadFixtureConfig(), setupManagerWithFixture()
  • toml/multi-sqlite.toml — Three in-memory SQLite databases (database_a, database_b, database_c)
  • toml/readonly-maxrows.toml — Sources with readonly/max_rows tool configurations

Usage:

import { setupManagerWithFixture, FIXTURES } from '../../__fixtures__/helpers.js';
const manager = await setupManagerWithFixture(FIXTURES.MULTI_SQLITE);
// ... test ...
await manager.disconnect();

Mocking Patterns

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 Testing

Integration tests use Testcontainers to run real database instances in Docker.

Prerequisites

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 Images

DatabaseImageNotes
PostgreSQLpostgres:15-alpineFast startup
MySQL@testcontainers/mysqlSupports IAM auth testing
MariaDB@testcontainers/mariadbSupports IAM auth testing
SQL Server@testcontainers/mssqlserverSlow startup (3-5 min), needs 4GB+ RAM
Oracle@testcontainers/oraclefree (gvenzl/oracle-free:23-slim-faststart)~1.2GB pull, 1-2 min startup, needs 2GB+ RAM
SQLiteNo container neededIn-memory or file-based

Troubleshooting

Container Startup Failures

docker ps                    # Verify Docker is running
docker system df             # Check disk space
docker pull postgres:15-alpine  # Manually pull images

SQL Server Timeouts

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

Test Isolation Issues

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

CI Failures

The CI workflow (.github/workflows/run-tests.yml) runs unit and integration tests as separate parallel jobs on PR events. Unit tests don't need Docker; integration tests verify Docker availability first. Check the specific job that failed.

Adding New Tests

Unit test: Create src/{module}/__tests__/{name}.test.ts — will auto-run with pnpm test:unit.

Integration test: Create src/{module}/__tests__/{name}.integration.test.ts — the integration in the filename is what routes it to pnpm test:integration.

New connector test: Extend IntegrationTestBase, implement the three abstract methods, and call the shared test suite methods.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.