Give each IRC listener test its own database (closes #129) #130

Merged
clawbot merged 1 commits from issue-129-own-test-database into next 2026-10-08 12:01:50 +02:00
Collaborator

Closes #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

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
clawbot added the needs-review label 2026-10-08 11:12:36 +02:00
clawbot self-assigned this 2026-10-08 11:12:36 +02:00
clawbot added 1 commit 2026-10-08 11:12:36 +02:00
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
Author
Collaborator

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 next 2026-10-08 12:01:50 +02:00
clawbot deleted branch issue-129-own-test-database 2026-10-08 12:01:51 +02:00
clawbot removed the needs-review label 2026-10-08 12:01:51 +02:00
Sign in to join this conversation.