Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SqlMock type to allow for options to be sent to function that creates the sqlmock #307

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Woody1193
Copy link

@Woody1193 Woody1193 commented Dec 22, 2022

This PR addresses an issue where the user wants to embed the SqlMock creation code into a function, like so:

func createServiceMock(database string, schema string, opts ...sqlmock.SqlMockOption) (*MyDB, sqlmock.Sqlmock) {

	db, mock, err := sqlmock.New(opts...)
	Expect(err).ShouldNot(HaveOccurred())

	svc := FromConnection(database, schema, db)

	return svc, mock
}

With the current implementation of go-sqlmock, this cannot done because the option references a type internal to the go-sqlmock package. By adding an alias for this type, the user can now send such options without exposing the internal sqlmock type.

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.

None yet

1 participant