Skip to content

Share one scratch-schema helper across the database-backed tests #754

Description

@keyxmakerx

Four test files now carry near-identical copies of the same helper. Each one parses CHRONICLE_TEST_DB_DSN, creates a scratch schema, applies migrations and drops the schema on cleanup:

  • internal/plugins/sessions/dbtest_support_test.go (newScratchDB)
  • internal/plugins/entities/repository_integration_test.go (openTestDB)
  • internal/plugins/timeline/repository_test.go (openTestDB, which also applies the calendar plugin's migrations)
  • internal/app/armory_npcs_visibility_leak_test.go (openGalleryTestDB)

Each copy is about 45 lines. One helper would remove about 130 lines, and the next DB-backed test couldn't get the make test-int-local DSN wrong again. That mistake is what #686 fixed. A helper package that takes the migration directories as arguments, for example internal/database/dbtest, would do it.

Watch out for two things:

  • tools/check-plugin-isolation.sh allowlists the timeline files by path.
  • The Fresh-DB CI job asserts these tests by name, so keep the test names.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions