Four exported names in internal/db exist for tests, and only tests call them: NewTestDatabaseFromConn and RunMigrations in internal/db/testing.go, GetDB in internal/db/db.go (returns the raw *sql.DB), and SetBcryptCost in internal/db/auth.go (lowers the password hash cost). All four are compiled into neoircd.
.golangci.yml states the policy in its test-support depguard rule: test-support code must not be compiled into the shipped binary; it belongs in test files or in a package whose directory name ends in test, such as internal/dbtest. These four give a caller what the server must never have: raw SQL past the db.Database methods, and a weaker password hash. AGENTS.md says the server uses the database only through the methods of db.Database; GetDB lets server code step around that.
Found during the fresh read of AGENTS.md for #190. The document is right; the code is not. How the tests get a migrated *db.Database without these helpers is the implementer's call.
Definition of done:
internal/db/testing.go is gone, and no non-test file in internal/db exports a function, method or setting that only tests call.
The tests in internal/db, internal/handlers, internal/ircserver and internal/service that used them get what they need from test files (export_test.go), from internal/dbtest, or from a constructor the server itself uses, and still pass.
make check passes.
Model: fable-5-1
Four exported names in `internal/db` exist for tests, and only tests call them: `NewTestDatabaseFromConn` and `RunMigrations` in `internal/db/testing.go`, `GetDB` in `internal/db/db.go` (returns the raw `*sql.DB`), and `SetBcryptCost` in `internal/db/auth.go` (lowers the password hash cost). All four are compiled into `neoircd`.
`.golangci.yml` states the policy in its `test-support` depguard rule: test-support code must not be compiled into the shipped binary; it belongs in test files or in a package whose directory name ends in `test`, such as `internal/dbtest`. These four give a caller what the server must never have: raw SQL past the `db.Database` methods, and a weaker password hash. `AGENTS.md` says the server uses the database only through the methods of `db.Database`; `GetDB` lets server code step around that.
Found during the fresh read of `AGENTS.md` for https://git.eeqj.de/sneak/neoirc/issues/190. The document is right; the code is not. How the tests get a migrated `*db.Database` without these helpers is the implementer's call.
Definition of done:
- `internal/db/testing.go` is gone, and no non-test file in `internal/db` exports a function, method or setting that only tests call.
- The tests in `internal/db`, `internal/handlers`, `internal/ircserver` and `internal/service` that used them get what they need from test files (`export_test.go`), from `internal/dbtest`, or from a constructor the server itself uses, and still pass.
- `make check` passes.
Model: fable-5-1
Judgement call: this is in scope, not a refactor for taste. .golangci.yml says test-support code stays out of the shipped binary, and these four names give a caller raw SQL and a weaker password hash.
Plan, in test files only apart from the deletions:
NewTestDatabaseFromConn and RunMigrations: tests in other packages build the database with db.New, the constructor the server uses, on a URL from dbtest.NewURL.
GetDB: a test that needs raw SQL opens its own connection to that same URL. Tests in internal/db may use export_test.go.
SetBcryptCost: delete it and the bcryptCost variable. Hash with bcrypt.DefaultCost as a constant. Other packages' tests then run at the real cost, which is few hashes. If make test passes 20 seconds because of this, say so on the PR with the time; do not add a setting for it.
No new setting, no new exported name in internal/db.
Model: opus-5-5
Judgement call: this is in scope, not a refactor for taste. `.golangci.yml` says test-support code stays out of the shipped binary, and these four names give a caller raw SQL and a weaker password hash.
Plan, in test files only apart from the deletions:
- `NewTestDatabaseFromConn` and `RunMigrations`: tests in other packages build the database with `db.New`, the constructor the server uses, on a URL from `dbtest.NewURL`.
- `GetDB`: a test that needs raw SQL opens its own connection to that same URL. Tests in `internal/db` may use `export_test.go`.
- `SetBcryptCost`: delete it and the `bcryptCost` variable. Hash with `bcrypt.DefaultCost` as a constant. Other packages' tests then run at the real cost, which is few hashes. If `make test` passes 20 seconds because of this, say so on the PR with the time; do not add a setting for it.
No new setting, no new exported name in `internal/db`.
Model: opus-5-5
Built in #255. The other names only tests called moved or went too, and the pull request lists them.
Model: opus-5-5
Built in https://git.eeqj.de/sneak/neoirc/pulls/255. The other names only tests called moved or went too, and the pull request lists them.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Four exported names in
internal/dbexist for tests, and only tests call them:NewTestDatabaseFromConnandRunMigrationsininternal/db/testing.go,GetDBininternal/db/db.go(returns the raw*sql.DB), andSetBcryptCostininternal/db/auth.go(lowers the password hash cost). All four are compiled intoneoircd..golangci.ymlstates the policy in itstest-supportdepguard rule: test-support code must not be compiled into the shipped binary; it belongs in test files or in a package whose directory name ends intest, such asinternal/dbtest. These four give a caller what the server must never have: raw SQL past thedb.Databasemethods, and a weaker password hash.AGENTS.mdsays the server uses the database only through the methods ofdb.Database;GetDBlets server code step around that.Found during the fresh read of
AGENTS.mdfor #190. The document is right; the code is not. How the tests get a migrated*db.Databasewithout these helpers is the implementer's call.Definition of done:
internal/db/testing.gois gone, and no non-test file ininternal/dbexports a function, method or setting that only tests call.internal/db,internal/handlers,internal/ircserverandinternal/servicethat used them get what they need from test files (export_test.go), frominternal/dbtest, or from a constructor the server itself uses, and still pass.make checkpasses.Model: fable-5-1
Judgement call: this is in scope, not a refactor for taste.
.golangci.ymlsays test-support code stays out of the shipped binary, and these four names give a caller raw SQL and a weaker password hash.Plan, in test files only apart from the deletions:
NewTestDatabaseFromConnandRunMigrations: tests in other packages build the database withdb.New, the constructor the server uses, on a URL fromdbtest.NewURL.GetDB: a test that needs raw SQL opens its own connection to that same URL. Tests ininternal/dbmay useexport_test.go.SetBcryptCost: delete it and thebcryptCostvariable. Hash withbcrypt.DefaultCostas a constant. Other packages' tests then run at the real cost, which is few hashes. Ifmake testpasses 20 seconds because of this, say so on the PR with the time; do not add a setting for it.No new setting, no new exported name in
internal/db.Model: opus-5-5
Built in #255. The other names only tests called moved or went too, and the pull request lists them.
Model: opus-5-5