Skip to content

arangodb: setupDB finishes the gomock controller early, so missing mock calls are never reported #4468

Open

Description

@NitinKumar004

Summary

setupDB in pkg/gofr/datasource/arangodb/arango_test.go creates the gomock controller and calls defer ctrl.Finish() inside the helper:

func setupDB(t *testing.T) (*Client, *MockClient, *MockUser, *MockLogger, *MockMetrics) {
	...
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	...
}

The deferred Finish runs when the helper returns, before the test sets any expectations. In go.uber.org/mock v0.6.0, Controller.Finish returns early when the controller is already finished (gomock/controller.go:268-273), so the t.Cleanup check that NewController registers never reports anything. As a result, a test that forgets to make an expected call still passes: missing calls in the arangodb tests are never reported.

This is the same bug as #4315 (cassandra, scylladb, dgraph), which #4358 fixes. arangodb was outside that issue's scope; this was raised in the review of #4358.

Suggested fix

  • Remove defer ctrl.Finish() from setupDB. gomock.NewController(t) already registers the check with t.Cleanup at the end of the test.
  • Then fix any test that starts failing: those are expectations that were never met and went unnoticed.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions