mocks

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterDriver

type ClusterDriver struct {
	// If defined, the #CreateSession function will throw this error.
	CreateSessionError string
	// This function gets executed by #CreateSession function
	// and can be used for mocking tests.
	// This function is always executed by #CreateSession if defined.
	MockCreateSession func()
}

ClusterDriver creates a mock gocql.ClusterConfig.

func (*ClusterDriver) CreateSession

func (cd *ClusterDriver) CreateSession() (*cql.Session, error)

CreateSession mocks the session-creation function for CassandraDriver. This function internally executes #MockCreationSession function.

type Iterx

type Iterx struct {
	CqlQuery   driver.QueryI
	MockClose  func() error
	MockSelect func(dest interface{}) error
}

Iterx mocks the gocqlx Iterx

func (*Iterx) Close

func (i *Iterx) Close() error

Close mocks the Iterx#Close function.

func (*Iterx) Select

func (i *Iterx) Select(dest interface{}) error

Select mocks the Iterx#Select function.

type Query

type Query struct {
	// If defined, the #Exec function will throw this error.
	ExecError       string
	MockExec        func()
	MockGetPageSize func() uint
	MockSetPageSize func(size uint)
	MockRelease     func()

	WrappedQuery *cql.Query
	// contains filtered or unexported fields
}

Query mocks the implementation for session-query.

func (*Query) Exec

func (q *Query) Exec() error

Exec mocks the query-execution

func (*Query) GetPageSize

func (q *Query) GetPageSize() uint

GetPageSize mocks fetching the current page-size. Being a mock, this doesn't actually store/track current page style. Use the function #SetPageSize along with this to completely mock page-size.

func (*Query) GoCqlQuery added in v1.1.1

func (q *Query) GoCqlQuery() *cql.Query

GoCqlQuery mocks the getter for wrapped GoCql-Query. The WrappedQuery member of Query must be explicitely set, else this will return a gocql.Query with just statement set.

func (*Query) Release

func (q *Query) Release()

Release mocks the #Release function driver.Query. It releases the query. Released queries cannot be reused.

func (*Query) SetPageSize

func (q *Query) SetPageSize(n uint) driver.QueryI

SetPageSize mocks the #SetPageSize function of driver.Query. SetPageSize tells the iterator to fetch the result in pages of size n. This is useful for iterating over large result sets.

func (*Query) Statement

func (q *Query) Statement() string

Statement returns the statement used to create query.

type Queryx

type Queryx struct {
	ColumnNames []string
	ExecError   string
	CqlQuery    driver.QueryI
	// Mock functions, called when respective implementations are executed
	MockBindMap     func(arg map[string]interface{})
	MockBindStruct  func()
	MockExecRelease func()
}

Queryx mocks the gocqlx Queryx

func (*Queryx) BindMap

func (q *Queryx) BindMap(arg map[string]interface{}) driver.QueryxI

BindMap mocks the map-binding for QueryxI. This binds query named parameters using Map.

func (*Queryx) BindStruct

func (q *Queryx) BindStruct(arg interface{}) driver.QueryxI

BindStruct mocks the struct-binding for QueryxI. This binds query named parameters to values from arg using mapper. If value cannot be found an error is reported.

func (*Queryx) ExecRelease

func (q *Queryx) ExecRelease() error

ExecRelease mocks the query execution and release for QueryxI

func (*Queryx) Query

func (q *Queryx) Query() driver.QueryI

Query returns the embedded gocql.Query.

func (*Queryx) Statement

func (q *Queryx) Statement() string

Statement returns the statement that was used to generate this query.

type Session

type Session struct {
	MockQuery          func(stmt string, values ...interface{})
	MockQueryExec      func()
	MockQueryExecError string
}

Session mocks the implementation for database connection-session.

func (*Session) GoCqlSession added in v1.1.1

func (s *Session) GoCqlSession() *cql.Session

GoCqlSession is a no-op

func (*Session) Query

func (s *Session) Query(stmt string, values ...interface{}) driver.QueryI

Query is mock for session's query-preparation function. This function internally executes #MockQuery function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL