mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-14 03:52:26 +08:00
fix(ci): check deferred sql.DB.Close errors in setup tests
PR #6499 merged without CI ever running on its head commit (fork run stayed action_required), landing three bare `defer db.Close()` calls in internal/setup/setup_test.go. The repo's errcheck config sets disable-default-exclusions: true, so those are reported and golangci-lint has been red on main ever since, failing every subsequent PR run. Switch them to the codebase's existing convention `defer func() { _ = db.Close() }()`.
This commit is contained in:
@@ -270,7 +270,7 @@ func TestDatabaseConnectionUsesConfiguredTargetBeforeBootstrapDatabase(t *testin
|
||||
if err != nil {
|
||||
t.Fatalf("sqlmock.New() error = %v", err)
|
||||
}
|
||||
defer targetDB.Close()
|
||||
defer func() { _ = targetDB.Close() }()
|
||||
|
||||
var opened []string
|
||||
openDatabase := func(_ *DatabaseConfig, dbName string) (*sql.DB, error) {
|
||||
@@ -292,12 +292,12 @@ func TestDatabaseConnectionUsesLegacyBootstrapOnlyForMissingTarget(t *testing.T)
|
||||
if err != nil {
|
||||
t.Fatalf("sqlmock.New() bootstrap error = %v", err)
|
||||
}
|
||||
defer bootstrapDB.Close()
|
||||
defer func() { _ = bootstrapDB.Close() }()
|
||||
targetDB, _, err := sqlmock.New()
|
||||
if err != nil {
|
||||
t.Fatalf("sqlmock.New() target error = %v", err)
|
||||
}
|
||||
defer targetDB.Close()
|
||||
defer func() { _ = targetDB.Close() }()
|
||||
|
||||
bootstrapMock.ExpectQuery(`SELECT EXISTS\(SELECT 1 FROM pg_database WHERE datname = \$1\)`).
|
||||
WithArgs(cfg.DBName).
|
||||
|
||||
Reference in New Issue
Block a user