Skip to content

test(api/federation): register mock.AssertExpectations on federationHandler() mock #44

Open

Description

@cristim

Problem

federationHandler() in internal/api/handler_federation_test.go creates a MockAuthService with a single ValidateSession stub but never registers t.Cleanup(func() { mockAuth.AssertExpectations(t) }). All 40+ federation tests that call federationHandler() inherit this gap.

Per the project feedback rule (feedback_mock_assert_expectations.md): every mock must have AssertExpectations registered via t.Cleanup so unmatched On stubs are caught as test failures rather than silently passing.

Fix

Refactor federationHandler() to accept a *testing.T parameter, register t.Cleanup(func() { mockAuth.AssertExpectations(t) }) inside it, and update all call sites. Since the same mockAuth is used for every federation test, this one change covers the entire file.

Discovered during adversarial review of PR LeanerCloud/cloud-commitments-cli#890 (was pre-existing, not introduced by that PR).

Activity

  1. IAmJSD commented on Oct 20, 2026

    @IAmJSD
    Collaborator

    Claiming: working on this

  2. self-assigned this
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions