From a4de16a1dd2a26d207b28fc7645dd1da33121746 Mon Sep 17 00:00:00 2001 From: wispem-wantex Date: Sat, 23 Aug 2025 18:46:27 -0700 Subject: [PATCH] Fix lint errors --- .gitea/workflows/CI.yaml | 1 + pkg/db/connect.go | 8 ++++---- pkg/db/connect_test.go | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/CI.yaml b/.gitea/workflows/CI.yaml index 1fcb298..dad20ca 100644 --- a/.gitea/workflows/CI.yaml +++ b/.gitea/workflows/CI.yaml @@ -11,6 +11,7 @@ jobs: env: GOPATH: /go-cache-volume GOCACHE: /go-cache-volume/build-cache + GOLANGCI_LINT_CACHE: /go-cache-volume/golangci-lint steps: - name: checkout env: diff --git a/pkg/db/connect.go b/pkg/db/connect.go index 290853a..dd2d347 100644 --- a/pkg/db/connect.go +++ b/pkg/db/connect.go @@ -11,8 +11,8 @@ import ( ) var ( - // Tracks whether the DB connector has been initialized - is_initialized bool + // // Tracks whether the DB connector has been initialized + // is_initialized bool // The SQL schema of the database under management sql_schema *string @@ -44,7 +44,7 @@ func Init(schema *string, migrationsList *[]string) { sql_schema = schema migrations = migrationsList version_number = uint(len(*migrations)) - is_initialized = true + // is_initialized = true } func Create(path string) (*sqlx.DB, error) { @@ -93,7 +93,7 @@ func CheckAndUpdateVersion(db *sqlx.DB) error { return nil } -// Run all the migrations from version X to version Y, and update the `database_version` table's `version_number` +// UpgradeFromXToY runs all the migrations from version X to version Y, and update the `database_version` table's `version_number` func UpgradeFromXToY(db *sqlx.DB, x uint, y uint) { for i := x; i < y; i++ { fmt.Print(ColorCyan) diff --git a/pkg/db/connect_test.go b/pkg/db/connect_test.go index 5e5adc8..ea9f0d7 100644 --- a/pkg/db/connect_test.go +++ b/pkg/db/connect_test.go @@ -51,12 +51,12 @@ func TestVersionUpgrade(t *testing.T) { get_version := func(c *sqlx.DB) (ret int) { // TODO: this should be a function exposed by the `db` package itself - c.Get(&ret, "select version from db_version") + require.NoError(c.Get(&ret, "select version from db_version")) return } var items []int - connection.Select(&items, "select * from items") + require.NoError(connection.Select(&items, "select * from items")) require.Len(items, 0) require.Equal(0, get_version(connection)) @@ -66,7 +66,7 @@ func TestVersionUpgrade(t *testing.T) { db.UpgradeFromXToY(connection, uint(len(migrations)-1), uint(len(migrations))) var items2 []int - connection.Select(&items2, "select * from items") + require.NoError(connection.Select(&items2, "select * from items")) require.Len(items2, 1) require.Equal(1, get_version(connection)) @@ -79,7 +79,7 @@ func TestVersionUpgrade(t *testing.T) { ID uint64 `db:"rowid"` Name string `db:"name"` } - connection.Select(&items3, "select * from items") + require.NoError(connection.Select(&items3, "select * from items")) require.Len(items2, 1) assert.Equal(t, "asdf", items3[0].Name) require.Equal(2, get_version(connection))