Each test environment in internal/ircserver opened a shared in-memory
database named after the test. When a test runs again in the same process, the
earlier run's server can still be holding that database open, so the new run
starts on the earlier run's users and fails while registering.
Changes, all in internal/ircserver/server_test.go:
The database gets a random name, so no two test environments share one.
The database close and the server stop are each registered with t.Cleanup
as soon as each is opened, instead of in one cleanup at the end of the setup.
A setup that fails part-way now still closes its database. Cleanups run in
reverse order, so the server still stops before its database closes.
New test TestEachTestEnvHasItsOwnDatabase opens two test environments in
one test and registers the same nick on both; it fails if they share a
database.
Worth knowing:
Stopping the server does not wait for its connection goroutines, so one can
still finish a database call just after its test ends. With a random name it
can only reach its own, already closed, database. Making the stop wait would
change the server itself, which this issue does not cover.
Judgement call: internal/handlers and internal/service name their
databases after the running test's address, and internal/db numbers them.
No two running tests share either, so they are unchanged.
Model: opus-5-5
Closes https://git.eeqj.de/sneak/neoirc/issues/129.
Each test environment in `internal/ircserver` opened a shared in-memory
database named after the test. When a test runs again in the same process, the
earlier run's server can still be holding that database open, so the new run
starts on the earlier run's users and fails while registering.
Changes, all in `internal/ircserver/server_test.go`:
- The database gets a random name, so no two test environments share one.
- The database close and the server stop are each registered with `t.Cleanup`
as soon as each is opened, instead of in one cleanup at the end of the setup.
A setup that fails part-way now still closes its database. Cleanups run in
reverse order, so the server still stops before its database closes.
- New test `TestEachTestEnvHasItsOwnDatabase` opens two test environments in
one test and registers the same nick on both; it fails if they share a
database.
Worth knowing:
- Stopping the server does not wait for its connection goroutines, so one can
still finish a database call just after its test ends. With a random name it
can only reach its own, already closed, database. Making the stop wait would
change the server itself, which this issue does not cover.
- Judgement call: `internal/handlers` and `internal/service` name their
databases after the running test's address, and `internal/db` numbers them.
No two running tests share either, so they are unchanged.
Model: opus-5-5
Each test environment in internal/ircserver named its shared in-memory
database after the test. A repeat run of a test in the same process
could open the database that an earlier run's server was still
holding, and start on that run's users. The database now gets a random
name, and a new test checks that two environments open at once do not
share one.
The database close and the server stop are now registered as soon as
each is opened, so a setup that fails part-way still closes its
database.
Model: opus-5-5
PASS: each IRC listener test environment now opens its own database, which meets the definition of done of #129.
Model: opus-5-5
PASS: each IRC listener test environment now opens its own database, which meets the definition of done of https://git.eeqj.de/sneak/neoirc/issues/129.
Model: opus-5-5
clawbot
merged commit a054bf828d into next2026-10-08 12:01:50 +02:00
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.
Closes #129.
Each test environment in
internal/ircserveropened a shared in-memorydatabase named after the test. When a test runs again in the same process, the
earlier run's server can still be holding that database open, so the new run
starts on the earlier run's users and fails while registering.
Changes, all in
internal/ircserver/server_test.go:t.Cleanupas soon as each is opened, instead of in one cleanup at the end of the setup.
A setup that fails part-way now still closes its database. Cleanups run in
reverse order, so the server still stops before its database closes.
TestEachTestEnvHasItsOwnDatabaseopens two test environments inone test and registers the same nick on both; it fails if they share a
database.
Worth knowing:
still finish a database call just after its test ends. With a random name it
can only reach its own, already closed, database. Making the stop wait would
change the server itself, which this issue does not cover.
internal/handlersandinternal/servicename theirdatabases after the running test's address, and
internal/dbnumbers them.No two running tests share either, so they are unchanged.
Model: opus-5-5
PASS: each IRC listener test environment now opens its own database, which meets the definition of done of #129.
Model: opus-5-5