fix: revert .golangci.yml to main, fix all lint issues in code
Some checks failed
check / check (push) Failing after 1m5s

- Restore original .golangci.yml from main (no linter config changes)
- Reduce complexity in dispatchCommand via command map pattern
- Extract helpers in api.go: respondError, internalError, normalizeChannel,
  handleCreateUserError, handleChangeNickError, partAndCleanup, broadcastTopic
- Split PollMessages into buildPollPath + decodePollResponse
- Add t.Parallel() to all tests, make subtests independent
- Extract test fx providers into named functions to reduce funlen
- Use mutex to serialize viper access in parallel tests
- Extract PRIVMSG constant, add nolint for gosec false positives
- Split long test functions into focused test cases
- Add blank lines before expressions per wsl_v5
This commit is contained in:
user
2026-02-26 20:45:47 -08:00
parent 69e1042e6e
commit 4b4a337a88
7 changed files with 723 additions and 543 deletions

View File

@@ -349,10 +349,12 @@ func TestSetTopic(t *testing.T) {
}
}
func TestInsertAndPollMessages(t *testing.T) {
t.Parallel()
func insertTestMessage(
t *testing.T,
database *db.Database,
) (int64, int64) {
t.Helper()
database := setupTestDB(t)
ctx := t.Context()
uid, _, err := database.CreateUser(ctx, "poller")
@@ -374,10 +376,19 @@ func TestInsertAndPollMessages(t *testing.T) {
t.Fatal(err)
}
return uid, dbID
}
func TestInsertAndPollMessages(t *testing.T) {
t.Parallel()
database := setupTestDB(t)
uid, _ := insertTestMessage(t, database)
const batchSize = 10
msgs, lastQID, err := database.PollMessages(
ctx, uid, 0, batchSize,
t.Context(), uid, 0, batchSize,
)
if err != nil {
t.Fatal(err)
@@ -400,7 +411,7 @@ func TestInsertAndPollMessages(t *testing.T) {
}
msgs, _, _ = database.PollMessages(
ctx, uid, lastQID, batchSize,
t.Context(), uid, lastQID, batchSize,
)
if len(msgs) != 0 {