chore: update golangci-lint config and fix lint issues (#542)

* chore: update golangci-lint config and fix lint issues
This commit is contained in:
Roger
2026-04-04 16:26:07 +08:00
committed by GitHub
parent e35907de6f
commit 92053b85b0
14 changed files with 116 additions and 138 deletions
+3 -3
View File
@@ -29,7 +29,7 @@ func TestCompressDir(t *testing.T) {
defer os.RemoveAll(tempDir)
err := CompressDir(tempDir)
assert.NoError(t, err, "compressDir should not return an error")
require.NoError(t, err, "compressDir should not return an error")
// Check if the zip file exists
zipFile := filepath.Join(tempDir, filepath.Base(tempDir)+".zip")
@@ -38,7 +38,7 @@ func TestCompressDir(t *testing.T) {
t.Run("Directory Does Not Exist", func(t *testing.T) {
err := CompressDir("/path/to/nonexistent/directory")
assert.Error(t, err, "should return an error for non-existent directory")
require.Error(t, err, "should return an error for non-existent directory")
})
t.Run("Empty Directory", func(t *testing.T) {
@@ -47,6 +47,6 @@ func TestCompressDir(t *testing.T) {
defer os.RemoveAll(tempDir)
err = CompressDir(tempDir)
assert.Error(t, err, "should return an error for an empty directory")
require.Error(t, err, "should return an error for an empty directory")
})
}
+6 -6
View File
@@ -34,7 +34,7 @@ func TestQuerySQLite(t *testing.T) {
return nil
})
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, []string{"alpha", "beta", "gamma"}, names)
}
@@ -59,7 +59,7 @@ func TestQuerySQLite_JournalOff(t *testing.T) {
values = append(values, v)
return nil
})
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, []string{"ok"}, values)
}
@@ -67,7 +67,7 @@ func TestQuerySQLite_FileNotFound(t *testing.T) {
err := QuerySQLite("/nonexistent/path.db", false, "SELECT 1", func(rows *sql.Rows) error {
return nil
})
assert.Error(t, err)
require.Error(t, err)
}
func TestQuerySQLite_BadQuery(t *testing.T) {
@@ -83,7 +83,7 @@ func TestQuerySQLite_BadQuery(t *testing.T) {
err = QuerySQLite(dbPath, false, "SELECT nonexistent FROM t", func(rows *sql.Rows) error {
return nil
})
assert.Error(t, err)
require.Error(t, err)
}
func TestQueryRows(t *testing.T) {
@@ -110,7 +110,7 @@ func TestQueryRows(t *testing.T) {
return u, err
})
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, []user{{"alice", 30}, {"bob", 25}}, users)
}
@@ -133,6 +133,6 @@ func TestQueryRows_Empty(t *testing.T) {
return v, nil
})
assert.NoError(t, err)
require.NoError(t, err)
assert.Nil(t, results)
}