Notre avis
Configure et exécute des tests d'intégration pour les adaptateurs dbt à l'aide de Testcontainers, en utilisant des instances de bases de données réelles dans des conteneurs Docker.
Points forts
- Vérifie la compatibilité réelle avec les dialectes SQL et les comportements spécifiques des bases de données.
- Isole chaque session de test dans un conteneur propre, garantissant reproductibilité et nettoyage automatique.
- Utilise des images Docker avec des tags précis pour des résultats cohérents.
- Optimise les performances avec des fixtures pytest de portée session ou module.
Limites
- Nécessite Docker et un environnement d'exécution de conteneurs.
- Le démarrage des conteneurs peut ralentir l'exécution des tests.
- Limité aux images de bases de données supportées par Testcontainers.
Lorsque vous devez tester des adaptateurs dbt contre des moteurs de bases de données réels pour détecter des problèmes de dialecte SQL ou de connexion.
Si des tests unitaires suffisent ou si Docker n'est pas disponible dans l'environnement de test.
Analyse de sécurité
PrudenceThe skill describes patterns for integration testing using Docker containers through testcontainers. While the content is legitimate, it involves container orchestration which carries inherent risks if not properly scoped. The skill itself does not contain destructive or exfiltrating commands, but Docker usage warrants caution.
- •Involves management of Docker containers via testcontainers, which is a powerful tool that could be misused if instructions are extended arbitrarily.
Exemples
Set up integration tests for a new Postgres dbt adapter using Testcontainers, including a pytest fixture that starts a Postgres container and a test that verifies table creation and data insertion.Write a pytest fixture that starts a DuckDB container for testing filesystem-dependent operations in a dbt adapter, and add a test that checks that reading and writing CSV files works correctly.Create an integration test for a BigQuery adapter using Testcontainers, testing partition extraction and query execution against a real BigQuery emulator or container.name: dbt-helpers-integration-testcontainers description: Set up and run integration tests using Testcontainers. Use when testing warehouse adapters against real database engines or verifying filesystem-dependent operations.
dbt-helpers-integration-testcontainers
Purpose
To verify that our adapters work correctly against real infrastructure, ensuring that SQL dialect nuances, connection edge cases, and filesystem behaviors are correctly handled.
Core Principles
- Isolation: Each test session should have its own clean container instance.
- Reproducibility: Use specific image tags (e.g.,
duckdb:latest,postgres:15) to ensure consistent results. - Efficiency: Use pytest fixtures with
sessionormodulescope where appropriate to minimize container startup overhead.
Patterns
1. Database Fixture
@pytest.fixture(scope="session")
def duckdb_container():
with DuckDBContainer("duckdb/duckdb:latest") as duckdb:
yield duckdb
@pytest.fixture
def catalog_client(duckdb_container):
return DuckDBCatalogClient(connection_url=duckdb_container.get_connection_url())
2. Cleanup
Always ensure containers are stopped and resources are cleaned up using context managers or yield fixtures.
Instructions
When writing integration tests
- Locate tests in
src/<package>/tests/integration/. - Use
testcontainers-pythonfor managing Docker instances. - Verify the adapter's behavior against the real engine (e.g., check that BQ partition info is correctly extracted).
When implementing a new warehouse adapter
- Create a corresponding integration test in the plugin package.
- Test both "happy path" and common failure modes (e.g., table not found, permission denied).
References
TDD Red-Green-Refactor
Testing
Skill qui guide Claude a travers le cycle TDD complet.
Audit d'Accessibilité Web
Testing
Réalise un audit d'accessibilité web complet selon les normes WCAG.
Générateur de Tests UAT
Testing
Génère des cas de test d'acceptation utilisateur structurés et complets.