golangci-lint: Bump to v2.0.2 and fix issues (#1871)

* build(deps): Bump golangci/golangci-lint-action from 6 to 7

Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6 to 7.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v6...v7)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* golangci-lint: Bump to v2 and fix issues

* refactor: remove no longer need ifshort nolint directives, fix test grammar and improve for loop logic

* nits: update order pair handling in tests and improve string replacement logic

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
dependabot[bot]
2025-04-02 15:36:05 +11:00
committed by GitHub
parent 1b7fa2259a
commit 179519a3c3
45 changed files with 342 additions and 304 deletions

View File

@@ -2,6 +2,7 @@ package testhelpers
import (
"database/sql"
"fmt"
"path/filepath"
"reflect"
@@ -41,27 +42,28 @@ func GetConnectionDetails() *database.Config {
// ConnectToDatabase opens connection to database and returns pointer to instance of database.DB
func ConnectToDatabase(conn *database.Config) (dbConn *database.Instance, err error) {
err = database.DB.SetConfig(conn)
if err != nil {
if err := database.DB.SetConfig(conn); err != nil {
return nil, err
}
if conn.Driver == database.DBPostgreSQL {
dbConn, err = psqlConn.Connect(conn)
if err != nil {
return nil, err
}
} else if conn.Driver == database.DBSQLite3 || conn.Driver == database.DBSQLite {
database.DB.DataPath = TempDir
dbConn, err = sqliteConn.Connect(conn.Database)
if err != nil {
return nil, err
}
}
err = migrateDB(database.DB.SQL)
switch conn.Driver {
case database.DBPostgreSQL:
dbConn, err = psqlConn.Connect(conn)
case database.DBSQLite3, database.DBSQLite:
database.DB.DataPath = TempDir
dbConn, err = sqliteConn.Connect(conn.Database)
default:
return nil, fmt.Errorf("unsupported database driver: %q", conn.Driver)
}
if err != nil {
return nil, err
}
if err := migrateDB(database.DB.SQL); err != nil {
return nil, err
}
database.DB.SetConnected(true)
return
}