Some checks failed
CI / Build & Test (push) Failing after 33s
- 37 个端点全部添加 godoc Swagger 注解(RBAC 11 / Org 5 / Audit 1 / Settings 7 / Notification 7) - 重新生成 docs/(swagger.json/yaml/docs.go) - M8 质量横切:IP 限流、安全头、Body 限制、结构化日志增强、优雅关闭 - 新增 Dockerfile 多阶段构建 + .dockerignore - 新增 testutil 测试工具包 - 修复 testutil.go 编译错误
46 lines
909 B
Go
46 lines
909 B
Go
package testutil
|
|
|
|
import (
|
|
"mengstack/internal/config"
|
|
"testing"
|
|
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap/zaptest"
|
|
)
|
|
|
|
// TestLogger returns a zap logger suitable for use in tests.
|
|
func TestLogger(t *testing.T) *zap.Logger {
|
|
return zaptest.NewLogger(t)
|
|
}
|
|
|
|
// TestConfig returns a minimal config for unit tests.
|
|
func TestConfig() *config.Config {
|
|
return &config.Config{
|
|
Server: config.ServerConfig{
|
|
Port: 0,
|
|
Mode: "test",
|
|
},
|
|
Database: config.DatabaseConfig{
|
|
Host: "localhost",
|
|
Port: 5432,
|
|
User: "test",
|
|
Password: "test",
|
|
DBName: "mengstack_test",
|
|
SSLMode: "disable",
|
|
},
|
|
Redis: config.RedisConfig{
|
|
Addr: "localhost:6379",
|
|
},
|
|
JWT: config.JWTConfig{
|
|
Secret: "test-secret",
|
|
AccessExpiryMinutes: 30,
|
|
RefreshExpiryDays: 7,
|
|
Issuer: "test",
|
|
},
|
|
Log: config.LogConfig{
|
|
Level: "debug",
|
|
Format: "console",
|
|
},
|
|
}
|
|
}
|