Fix lint errors
All checks were successful
CI / release-test (push) Successful in 49s

This commit is contained in:
wispem-wantex 2025-08-23 18:46:27 -07:00
parent 53785b6e6e
commit a4de16a1dd
3 changed files with 9 additions and 8 deletions

View File

@ -11,6 +11,7 @@ jobs:
env: env:
GOPATH: /go-cache-volume GOPATH: /go-cache-volume
GOCACHE: /go-cache-volume/build-cache GOCACHE: /go-cache-volume/build-cache
GOLANGCI_LINT_CACHE: /go-cache-volume/golangci-lint
steps: steps:
- name: checkout - name: checkout
env: env:

View File

@ -11,8 +11,8 @@ import (
) )
var ( var (
// Tracks whether the DB connector has been initialized // // Tracks whether the DB connector has been initialized
is_initialized bool // is_initialized bool
// The SQL schema of the database under management // The SQL schema of the database under management
sql_schema *string sql_schema *string
@ -44,7 +44,7 @@ func Init(schema *string, migrationsList *[]string) {
sql_schema = schema sql_schema = schema
migrations = migrationsList migrations = migrationsList
version_number = uint(len(*migrations)) version_number = uint(len(*migrations))
is_initialized = true // is_initialized = true
} }
func Create(path string) (*sqlx.DB, error) { func Create(path string) (*sqlx.DB, error) {
@ -93,7 +93,7 @@ func CheckAndUpdateVersion(db *sqlx.DB) error {
return nil 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) { func UpgradeFromXToY(db *sqlx.DB, x uint, y uint) {
for i := x; i < y; i++ { for i := x; i < y; i++ {
fmt.Print(ColorCyan) fmt.Print(ColorCyan)

View File

@ -51,12 +51,12 @@ func TestVersionUpgrade(t *testing.T) {
get_version := func(c *sqlx.DB) (ret int) { get_version := func(c *sqlx.DB) (ret int) {
// TODO: this should be a function exposed by the `db` package itself // 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 return
} }
var items []int var items []int
connection.Select(&items, "select * from items") require.NoError(connection.Select(&items, "select * from items"))
require.Len(items, 0) require.Len(items, 0)
require.Equal(0, get_version(connection)) 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))) db.UpgradeFromXToY(connection, uint(len(migrations)-1), uint(len(migrations)))
var items2 []int var items2 []int
connection.Select(&items2, "select * from items") require.NoError(connection.Select(&items2, "select * from items"))
require.Len(items2, 1) require.Len(items2, 1)
require.Equal(1, get_version(connection)) require.Equal(1, get_version(connection))
@ -79,7 +79,7 @@ func TestVersionUpgrade(t *testing.T) {
ID uint64 `db:"rowid"` ID uint64 `db:"rowid"`
Name string `db:"name"` Name string `db:"name"`
} }
connection.Select(&items3, "select * from items") require.NoError(connection.Select(&items3, "select * from items"))
require.Len(items2, 1) require.Len(items2, 1)
assert.Equal(t, "asdf", items3[0].Name) assert.Equal(t, "asdf", items3[0].Name)
require.Equal(2, get_version(connection)) require.Equal(2, get_version(connection))