-
Notifications
You must be signed in to change notification settings - Fork 41
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
Introduce Functional Options for MsSQL Connector #1089
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resubmitting comments from @diverdane
// ServerPreloginResponse => map[uint8][]byte{} | ||
// ServerLoginResponse => &mssql.LoginResponse{} | ||
// BackendConn => nil | ||
// BackendConn => nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quote @diverdane
Do we want to use 'options' here instead of 'setters', per Johah's previous comment, or is this used intentionally to distinguish this from ConnectorOptions?
internal/plugin/connectors/tcp/mssql/production_options_test.go
Outdated
Show resolved
Hide resolved
internal/plugin/connectors/tcp/mssql/production_options_test.go
Outdated
Show resolved
Hide resolved
- NewSingleUseConnectorWithOptions allows custom injection of dependencies without needing to specify all of them - ConnectorOptions struct captures all the configuration options for a SingleUseConnector - ConnectorOption is the 'functional option' complement to ConnectorOptions - Implemented
- Introduce tests that cover the 'production' options - dependencies we will use during production. - Covers each option specified in the singleuseconnector - Introduces mock options structure used for unit testing, including a function which returns default options
- Unit tests now make use of the t.Run structure, where each test can be ran from within a single connect function - Introduces helper functions for testing around failure - Makes use of the new functional options feature in the connector
7bde982
to
ccdac7e
Compare
SingleUseConnector now has types.ConnectorOptions as an embedded type, allowing us to skip an additional constructor method NewSingleUseConnectorWithOptions has been moved to the connector_test.go
NewSingleUseConnectorWithOptions is now package private in connector_test.go Ordered chronologically the tests in prod_options_test Made DefaultConnectorOptions a variable in options.go
- WriteLogin Succeeds - WriteLogin Fails - ReadLogin Succeeds - ReadLogin Fails
This change adds a test case for a failing readPrelogin call
- WritePreloginSucceeds test - The production version of WritePreloginWithPacketType succeeds when all others succeed - We receive the prelogin fields from the go-mssqldb driver - We modify the prelogin fields before sending them to the user - WritePreloginFails test - Error is returned from connect - Error is written to client buffer - Error written to log
ccdac7e
to
8e072c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does this PR do (include background context, if relevant)?
This PR is focused on improving the foundation of our current MsSQL tests, reducing code reuse and time needed to build new unit tests for the connector. It additionally includes a division between tests for our connector, and tests for our production options.
This is a re-uploaded PR of @doodlesbykumbi's work. All credit should go to him.
What ticket does this PR close?
Connected to:
#1010
#1073
Where should the reviewer start?
internal/plugin/connectors/tcp/mssql/connector_test.go
What is the status of the manual tests?
Have you run the following manual tests to verify existing functionality continues to function as expected?
NA
If this feature does not have any/sufficent automated tests, have you created/updated a folder in
test/manual
that includes:NA
Links to open issues for related automated integration and unit tests
NA
Links to open issues for related documentation (in READMEs, docs, etc)
NA
Screenshots (if appropriate)
NA