Skip to content

SCM observer: end-to-end integration test #109

@harshitsinghbhandari

Description

@harshitsinghbhandari

The SCM observer has 21 unit tests in backend/internal/observe/scm/observer_test.go and 4 store tests in backend/internal/storage/sqlite/store/store_test.go covering WriteSCMObservation, but there is no test that wires the observer to a real SQLite store and a real Lifecycle Manager and asserts the end-to-end behavior. backend/internal/integration/lifecycle_sqlite_test.go does not touch observe/scm (grep confirms zero matches). This is the largest single test gap on the SCM lane and the most likely place for a regression to land silently — the kind of regression that the messenger-and-origin wiring issue (#108) is specifically vulnerable to.

Acceptance

A new test file backend/internal/integration/scm_observer_test.go that:

  • Constructs a real sqlite.Store against a tmpdir DB.
  • Constructs a real lifecycle.Manager with a recording in-memory messenger spy.
  • Constructs a fake observe/scm.Provider returning canned ports.SCMObservation values keyed by PR.
  • Wires observe/scm.New(provider, store, lcm, Config{Tick: time.Hour}) and drives Poll(ctx) directly (do not rely on the ticker).
  • Asserts, for a CI-failing observation:
    • The pr row reflects the observation (provider-neutral columns, hashes set).
    • pr_checks rows match the observation's CI.Checks.
    • Exactly one nudge reached the messenger, containing the log tail.
    • A second identical Poll produces zero new nudges (idempotency).
  • Asserts, for a Merged: true observation, that the session is MarkTerminated'd and no nudge is sent.
  • Asserts, for a branch with no open PR, that nothing is written and no nudge is sent.

PR #87 carries internal/integration/prpoller_functional_test.go with this exact shape on the older observe/prpoller design — translate the assertions onto observe/scm.Observer + ApplySCMObservation and keep the test.

Why now

This test is the regression guard for #108. Land it after #108 (or in the same PR) so the wired behavior stays wired.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    scmSCM observer/notifier lane

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions