go-integration-tests

Generate Go integration tests with PostgreSQL containers and automated migrations.

Updated Jan 17, 2026
One-click install
npx skills add https://github.com/saddam-eng-tech/ai-agent-skills --skill go-integration-tests-saddam-eng-tech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-integration-tests
Source: https://github.com/saddam-eng-tech/ai-agent-skills/tree/main/go-integration-tests
Command: npx skills add https://github.com/saddam-eng-tech/ai-agent-skills --skill go-integration-tests-saddam-eng-tech

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the limitations of mock-based testing in Go by setting up integration tests that use a real PostgreSQL database, ensuring that database interactions and migrations are tested accurately.

Core Features & Use Cases

  • Real Database Testing: Utilizes testcontainers-go to spin up a PostgreSQL instance for tests.
  • Automated Migrations: Runs database migrations automatically before tests execute.
  • Per-Test Isolation: Ensures each test has a clean, isolated database state.
  • Use Case: Automatically generate a robust integration test suite for a new Go microservice's data layer, catching subtle bugs that unit tests with sqlmock might miss.

Quick Start

Set up integration tests for my Go module at 'internal/app' with migrations in 'migrations/' and testing the 'User' repository.

Frequently Asked Questions about go-integration-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Go integration tests with a real Postgres database?

Go integration tests with a real Postgres database use testcontainers-go to spin up a PostgreSQL container, automatically execute database migrations, and provide per-test isolation to catch real SQL bugs.

Why use testcontainers-go for Go integration tests instead of mocks?

Using testcontainers-go instead of mocks validates actual database interactions and migrations against a real PostgreSQL instance, catching subtle SQL bugs that unit tests with sqlmock might miss.

How do I isolate database state for each test in a Go integration test suite?

You isolate database state for each test by applying per-test database isolation, ensuring every test executes against a clean database state after running automated migrations.

What inputs do I need to generate a Go integration test suite for my repository?

To generate a Go integration test suite for your repository, you need to provide the module path, the migration directory path, and the entity or repository names as inputs to scaffold the test cases.

When should I use real PostgreSQL containers over sqlmock in Go testing?

You should use real PostgreSQL containers over sqlmock in Go testing when you need to test database interactions and migrations accurately, automatically executing migrations before tests to catch real SQL bugs that mocks miss.