Documentation
¶
Overview ¶
Package testing provides testing utilities for gorp framework. This file provides container setup helpers for integration tests. Creates test container with config, logger, DB, Redis capabilities.
测试包提供 gorp 框架的测试工具能力。 本文件提供用于集成测试的容器设置 helper。 创建携带 config、logger、DB、Redis 能力的测试容器。
Package testing provides testing utilities for gorp framework. This file provides environment variable helpers for tests. Sets env and returns restore func for cleanup.
测试包提供 gorp 框架的测试工具能力。 本文件提供环境变量测试 helper。 设置环境变量并返回 restore 函数用于清理。
Package testing provides testing utilities for gorp framework. This file provides working directory helpers for tests. Changes working directory to repo root where go.mod lives.
测试包提供 gorp 框架的测试工具能力。 本文件提供工作目录测试 helper。 切换工作目录到 go.mod 所在的仓库根目录。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChdirRepoRoot ¶
func ChdirRepoRoot() error
ChdirRepoRoot changes working directory to the repo root (where go.mod lives). 注意:进程级副作用,同一进程内并行测试会互相影响;尽量用 ChdirRepoRootRestore 并在 cleanup 中恢复。
func ChdirRepoRootRestore ¶ added in v0.2.0
func ChdirRepoRootRestore() (func(), error)
ChdirRepoRootRestore 切到仓库根目录并返回恢复函数(切回原工作目录)。 避免 ChdirRepoRoot 的进程级副作用污染同进程内的其他测试。
func NewTestContainer ¶
func NewTestContainer(t *testing.T) (runtimecontract.Container, cleanupFunc)
NewTestContainer builds a container configured for tests: - APP_ENV=testing - miniredis Restores env vars and working directory on cleanup to avoid cross-test pollution.
Types ¶
This section is empty.