All checks were successful
check / check (push) Successful in 2m48s
Bump the golangci-lint Docker image pin in Dockerfile and the release-archive sha256 pins in script/bootstrap from 2.11.3 to 2.12.2, and replace .golangci.yml with the canonical config. The canonical config moves lll/funlen/cyclop/dupl settings from the top-level linters-settings key (ignored by the v2 schema) to linters.settings, so those thresholds now actually apply. Fix all findings the newly applied thresholds surfaced: - lll: wrap or shorten seven over-length lines (struct tag comments, test logger construction, a func signature, and a nosec comment) - goconst: use http.MethodPost/http.MethodPut and new shared constants for repeated test strings; add tmplKeyError and tmplKeyWebhook constants for template data keys in handlers - dupl: merge buildHTTPTargetConfig and buildSlackTargetConfig into a parameterized buildURLTargetConfig; drop the duplicate iWebhookDB test helper in favor of testWebhookDB; extract shared helpers in middleware and session tests
35 lines
865 B
Go
35 lines
865 B
Go
package database
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// NewTestDatabase creates a Database wrapper around a pre-opened *gorm.DB.
|
|
// Intended for use in tests that need a *database.Database without the
|
|
// full fx lifecycle. The caller is responsible for closing the underlying
|
|
// sql.DB connection.
|
|
func NewTestDatabase(db *gorm.DB) *Database {
|
|
return &Database{
|
|
db: db,
|
|
log: slog.New(slog.NewTextHandler(
|
|
os.Stderr,
|
|
&slog.HandlerOptions{Level: slog.LevelDebug},
|
|
)),
|
|
}
|
|
}
|
|
|
|
// NewTestWebhookDBManager creates a WebhookDBManager backed by the given
|
|
// data directory. Intended for use in tests without the fx lifecycle.
|
|
func NewTestWebhookDBManager(dataDir string) *WebhookDBManager {
|
|
return &WebhookDBManager{
|
|
dataDir: dataDir,
|
|
log: slog.New(slog.NewTextHandler(
|
|
os.Stderr,
|
|
&slog.HandlerOptions{Level: slog.LevelDebug},
|
|
)),
|
|
}
|
|
}
|