go-testing

Test Go backend services with mocked sqlc queries, testcontainers-go, and httptest.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/NoahYn/climb.com --skill go-testing-noahyn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-testing
Source: https://github.com/NoahYn/climb.com/tree/main/.claude/skills/go-testing
Command: npx skills add https://github.com/NoahYn/climb.com --skill go-testing-noahyn

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill provides comprehensive guidance and patterns for effectively testing Go backend applications, ensuring code quality and reliability across different layers of the application.

Core Features & Use Cases

  • Unit Testing: Mocking dependencies (like database queries) to test individual service components in isolation.
  • Integration Testing: Using testcontainers-go to spin up real dependencies (like PostgreSQL) for end-to-end testing of integrated components.
  • HTTP Handler Testing: Utilizing net/http/httptest to simulate HTTP requests and test API endpoints.
  • Test Utilities: Implementing reusable test fixtures, helper functions, and mock implementations.
  • Coverage: Guidance on achieving and maintaining high test coverage.

Quick Start

Use the go-testing skill to write unit tests for your Go services by mocking sqlc database queries.

Frequently Asked Questions about go-testing

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

FAQPage Schema
How do I mock sqlc database queries for Go backend unit testing?

To mock sqlc database queries for Go backend unit testing, implement mock interfaces that isolate service components. This approach allows testing individual layers in isolation without hitting a real database, ensuring fast and reliable execution.

How does testcontainers-go work for Go integration testing with PostgreSQL?

Testcontainers-go works for Go integration testing by spinning up real PostgreSQL instances in Docker containers during test execution. This provides an isolated, end-to-end environment to validate integrated components against actual database behavior.

What is the best way to test HTTP handlers in Go?

The best way to test HTTP handlers in Go is using the net/http/httptest package. It simulates HTTP requests and records responses, enabling precise endpoint testing without requiring a live server.

Do I need table-driven tests for Go backend services?

You need table-driven tests for Go backend services to efficiently validate multiple input scenarios. They organize test cases into structs, reducing code duplication and making coverage of edge cases easier to maintain.

When should I use testcontainers-go instead of mocking for Go tests?

Use testcontainers-go instead of mocking for Go tests when validating actual database interactions. Mocking isolates components for fast unit tests, while testcontainers-go provides realistic integration testing with real PostgreSQL instances.