CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/go-api-testing

Go API testing patterns -- httptest setup, table-driven tests with subtests, test helpers, middleware testing, dependency injection with interfaces, database isolation, parallel tests, testify assertions, golden files

98

1.06x
Quality

98%

Does it follow best practices?

Impact

99%

1.06x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

test-go-dependency-injection.jsonverifiers/

{
  "instruction": "Write tests for a Go API service that uses interfaces for dependency injection. Define a mock/fake implementation of the service interface for testing, and test handlers with both success and error scenarios by configuring the mock.",
  "relevant_when": "Agent writes tests for a Go service with external dependencies",
  "context": "Proactively verify that agents use Go interfaces for dependency injection in tests: define an interface for the dependency, create a mock/fake struct that implements it, and inject the mock into handlers during tests.",
  "sources": [
    {
      "type": "file",
      "filename": "skills/go-api-testing/SKILL.md",
      "tile": "tessl-labs/go-api-testing"
    }
  ],
  "checklist": [
    {
      "name": "interface-defined",
      "rule": "An interface is defined for the external dependency (e.g., UserStore, Repository, Service) with the methods the handler needs",
      "relevant_when": "Agent designs testable Go code"
    },
    {
      "name": "mock-implements-interface",
      "rule": "A mock/fake struct in _test.go implements the dependency interface with configurable behavior (e.g., returning preset data or errors)",
      "relevant_when": "Agent creates test doubles"
    },
    {
      "name": "mock-injected-into-handler",
      "rule": "The handler/service under test accepts the interface (not a concrete type) and the mock is injected in test setup",
      "relevant_when": "Agent sets up handler tests with dependency injection"
    },
    {
      "name": "success-and-error-paths",
      "rule": "Tests cover both success scenarios (mock returns valid data) and error scenarios (mock returns an error) to verify error handling",
      "relevant_when": "Agent tests handlers with injected dependencies"
    },
    {
      "name": "mock-in-test-file",
      "rule": "The mock/fake struct is defined in a _test.go file, not in production code",
      "relevant_when": "Agent creates mock implementations"
    },
    {
      "name": "no-external-mock-framework",
      "rule": "Tests use a hand-written mock struct rather than a code-generation mock framework (gomock, mockery) for simple interfaces -- keeps tests readable and dependency-free",
      "relevant_when": "Agent decides how to create test doubles"
    }
  ]
}

tile.json