Skip to content

chore: improve testing of notifications in coderd tests #15481

Open
@johnstcn

Description

@johnstcn

Problem

Right now, coderdtest uses a fake notifications enqueuer implementation that simply stores an internal list of enqueued notification messages.
The 'real' implementation actually stores enqueued notification messages in the database.
End result: integration tests end up not checking dbauthz RBAC.
This is partially addressed in #15478 but the actual implemention is not 100% in line with reality.

Proposed solution

Our tests in coderd should use the 'real' notifications.StoreEnqueuer, and enqueued notifications should be stored in the configured database.Store used by the tests.

However, there are some ergonomics considerations to be considered here, as tests will generally want to:

  • Perform some action
  • Wait for a notification to be enqueued asynchronously
  • Perform assertions on the notification

Right now, we would need to resort to polling in order to accomplish this.

An option is to place a thin wrapper around notifications.StoreEnqueuer that exposes the following methods to tests:

  • Wait for a notification to be enqueued successfully
  • Fetch all enqueued notifications
  • Clear all enqueued notifications

cc @dannykopping

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug riskProne to bugss4Internal bugs (e.g. test flakes), extreme edge cases, and bug risks

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions