Documentation ¶
Index ¶
- Variables
- func CustomNewMSSQLConnectorOption(ctor MSSQLConnectorCtor) types.ConnectorOption
- func FakeTdsBufferCtor(r io.ReadWriteCloser) io.ReadWriteCloser
- func NewFailingMSSQLConnector(err error) types.MSSQLConnector
- func NewFailingMSSQLConnectorCtor(err error) types.MSSQLConnectorCtor
- func NewSuccessfulMSSQLConnector(fn func(context.Context) (net.Conn, error)) types.MSSQLConnector
- func NewSuccessfulMSSQLConnectorCtor(fn types.MSSQLConnectorFunc) types.MSSQLConnectorCtor
- func SuccessfulReadLoginRequest(io.ReadWriteCloser) (*mssql.LoginRequest, error)
- func SuccessfulReadPreloginRequest(io.ReadWriteCloser) (map[uint8][]byte, error)
- func SuccessfulWriteError(io.ReadWriteCloser, mssql.Error) error
- func SuccessfulWritePreloginResponse(io.ReadWriteCloser, map[uint8][]byte) error
- type MSSQLConnectorCtor
- type NetConn
Constants ¶
This section is empty.
Variables ¶
var DefaultConnectorOptions types.ConnectorOption = func(connectOptions *types.ConnectorOptions) { connectOptions.Logger = logmock.NewLogger() connectOptions.ReadPreloginRequest = SuccessfulReadPreloginRequest connectOptions.WritePreloginResponse = SuccessfulWritePreloginResponse connectOptions.ReadLoginRequest = SuccessfulReadLoginRequest connectOptions.WriteError = SuccessfulWriteError connectOptions.NewTdsBuffer = FakeTdsBufferCtor connectOptions.NewMSSQLConnector = DefaultNewMSSQLConnector }
DefaultConnectorOptions is a 'functional option' containing the default successful methods of each dependency
var DefaultMSSQLConnectorCtor = MSSQLConnectorCtor{ BackendConn: NewNetConn(nil), Err: nil, ServerPreloginResponse: map[uint8][]byte{}, ClientLoginRequestPtr: nil, }
DefaultMSSQLConnectorCtor is the default constructor for MSSQLConnectorCtor
var DefaultNewMSSQLConnector = NewSuccessfulMSSQLConnectorCtor( func(ctx context.Context) (net.Conn, error) { interceptor := mssql.ConnectInterceptorFromContext(ctx) interceptor.ServerPreLoginResponse <- DefaultMSSQLConnectorCtor.ServerPreloginResponse <-interceptor.ClientLoginRequest return DefaultMSSQLConnectorCtor.BackendConn, DefaultMSSQLConnectorCtor.Err }, )
DefaultNewMSSQLConnector returns an always successful MSSQLConnectorCtor
Functions ¶
func CustomNewMSSQLConnectorOption ¶ added in v1.5.0
func CustomNewMSSQLConnectorOption(ctor MSSQLConnectorCtor) types.ConnectorOption
CustomNewMSSQLConnectorOption allows us to inject a custom MSSQLConnectorCtor to control the output of the connect method
func FakeTdsBufferCtor ¶
func FakeTdsBufferCtor(r io.ReadWriteCloser) io.ReadWriteCloser
FakeTdsBufferCtor returns the ReadWriteCloser passed in.
func NewFailingMSSQLConnector ¶
func NewFailingMSSQLConnector(err error) types.MSSQLConnector
NewFailingMSSQLConnector returns an MSSQLConnector double whose Connect method always fails.
func NewFailingMSSQLConnectorCtor ¶
func NewFailingMSSQLConnectorCtor(err error) types.MSSQLConnectorCtor
NewFailingMSSQLConnectorCtor returns an MSSQLConnectorCtor that always returns the specified error.
func NewSuccessfulMSSQLConnector ¶
func NewSuccessfulMSSQLConnector( fn func(context.Context) (net.Conn, error), ) types.MSSQLConnector
NewSuccessfulMSSQLConnector returns an MSSQLConnector double whose Connect method always succeeds.
func NewSuccessfulMSSQLConnectorCtor ¶
func NewSuccessfulMSSQLConnectorCtor( fn types.MSSQLConnectorFunc, ) types.MSSQLConnectorCtor
NewSuccessfulMSSQLConnectorCtor returns an MSSQLConnectorCtor that always succeeds.
func SuccessfulReadLoginRequest ¶ added in v1.5.0
func SuccessfulReadLoginRequest(io.ReadWriteCloser) (*mssql.LoginRequest, error)
SuccessfulReadLoginRequest is a double for a ReadLoginRequestFunc that always succeeds.
func SuccessfulReadPreloginRequest ¶ added in v1.5.0
func SuccessfulReadPreloginRequest(io.ReadWriteCloser) (map[uint8][]byte, error)
SuccessfulReadPreloginRequest is a double for a ReadPreloginRequestFunc that always succeeds.
func SuccessfulWriteError ¶ added in v1.5.0
func SuccessfulWriteError(io.ReadWriteCloser, mssql.Error) error
SuccessfulWriteError is a double for a WriteErrorFunc that always succeeds.
func SuccessfulWritePreloginResponse ¶ added in v1.5.0
func SuccessfulWritePreloginResponse(io.ReadWriteCloser, map[uint8][]byte) error
SuccessfulWritePreloginResponse is a double for a WritePreloginResponseFunc that always succeeds.
Types ¶
type MSSQLConnectorCtor ¶ added in v1.5.0
type MSSQLConnectorCtor struct { // Backend connection returned from the call to Connect BackendConn net.Conn // Error returned from the call to Connect Err error // PreloginResponse from the server passed to interceptor during Connect ServerPreloginResponse map[uint8][]byte // Pointer to unload client login request to, taken from interceptor during Connect ClientLoginRequestPtr **mssql.LoginRequest }
MSSQLConnectorCtor is a mock which represents options when creating a mssql.MSSQLConnectorCtor. This makes it possible to customize some key values in a Connect double: func Connect(...) (net.Conn, error)
type NetConn ¶
NetConn acts as a double of a true network connection, ie, a net.Conn. TODO: This will need to be upgraded to have more granularity. For example,
to handle cases where sending the authentication OK message works, but sending an error fails. Etc.
func NewNetConn ¶
NewNetConn returns a net.Conn double whose behavior we can control.