Skip to content

LWLP-1215: bugfix: DAO test fixtures breaking - #1721

Open
etsien wants to merge 1 commit into
content-services:mainfrom
etsien:dao-test-soft-delete-bugfix
Open

etsien wants to merge 1 commit into
content-services:mainfrom
etsien:dao-test-soft-delete-bugfix

Conversation

@etsien

@etsien etsien commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Soft-delete committed lightwell RepositoryConfiguration rows (org_id -3, -4) at the start of each DAO test transaction in DaoSuite.SetupTest(). This prevents committed lightwell repos from leaking into test assertions that assume a clean database. The Rollback() in TearDownTest() restores the rows, so no data is permanently affected.

The fix is a 3-line addition in pkg/dao/suite_test.go. No test assertions, seed data, or production code change.

Testing Steps (reproduction)

  1. Start the local database:

    make db-up db-migrate-up
  2. Seed lightwell repos to simulate a developer who has run the importer:

    podman exec cs_postgres-content_1 psql -U content -d content -c "
    INSERT INTO repositories (uuid, created_at, updated_at, url, origin, content_type, public)
    VALUES
      ('aaaaaaaa-0000-0000-0000-000000000001', now(), now(), 'https://repo.maven.apache.org/maven2/', 'lightwell', 'maven', false),
      ('aaaaaaaa-0000-0000-0000-000000000002', now(), now(), 'https://pypi.org/', 'lightwell', 'python', false)
    ON CONFLICT DO NOTHING;
    
    INSERT INTO repository_configurations (uuid, created_at, updated_at, name, label, arch, versions, org_id, repository_uuid)
    VALUES
      ('bbbbbbbb-0000-0000-0000-000000000001', now(), now(), 'maven-test', 'maven-test', 'any', '{any}', '-3', 'aaaaaaaa-0000-0000-0000-000000000001'),
      ('bbbbbbbb-0000-0000-0000-000000000002', now(), now(), 'python-test', 'python-test', 'any', '{any}', '-3', 'aaaaaaaa-0000-0000-0000-000000000002')
    ON CONFLICT DO NOTHING;
    "

    These rows have NULL feature_name, which passes the feature gate unconditionally.

  3. Without the fix (on main), confirm the tests fail:

    CONFIG_PATH="$(pwd)/configs/" go test ./pkg/dao/... -count=1 -timeout=180s \
      -run "TestRepositoryConfigSuite/(TestListNoRepositories|TestListPageLimit|TestListFilterOrigin|TestListFilterExtendedRelease|TestListFilterStatus)" -v
  4. With the fix, confirm all tests pass:

    CONFIG_PATH="$(pwd)/configs/" go test ./pkg/dao/... -count=1 -timeout=180s \
      -run "TestRepositoryConfigSuite" -v
  5. Confirm TestAdminTaskSuite/TestSort still passes:

    CONFIG_PATH="$(pwd)/configs/" go test ./pkg/dao/... -count=1 -timeout=60s \
      -run "TestAdminTaskSuite/TestSort" -v

@etsien
etsien requested a review from a team as a code owner September 10, 2026 17:38
@etsien etsien changed the title LWLP-1215: DAO test fixtures break when more repos are added (e.g. python, npm) LWLP-1215: bugfix: DAO test fixtures breaking Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant