Documentation
¶
Index ¶
- Variables
- type Collection
- func (c *Collection) Count() (uint64, error)
- func (c *Collection) Exists() (bool, error)
- func (c *Collection) ExpectCount(e *CollectionCountExpectation)
- func (c *Collection) ExpectCountArgs(retResult uint64, retError error)
- func (c *Collection) ExpectExists(e *CollectionExistsExpectation)
- func (c *Collection) ExpectExistsArgs(retResult bool, retError error)
- func (c *Collection) ExpectInsert(e *CollectionInsertExpectation)
- func (c *Collection) ExpectInsertArgs(item interface{}, retID interface{}, retError error)
- func (c *Collection) ExpectInsertReturning(e *CollectionInsertReturningExpectation)
- func (c *Collection) ExpectInsertReturningArgs(item interface{}, retItem interface{}, retError error)
- func (c *Collection) ExpectTruncate(e *CollectionTruncateExpectation)
- func (c *Collection) ExpectTruncateArgs(retError error)
- func (c *Collection) ExpectUpdateReturning(e *CollectionUpdateReturningExpectation)
- func (c *Collection) ExpectUpdateReturningArgs(item interface{}, retItem interface{}, retError error)
- func (c *Collection) Find(args ...interface{}) db.Result
- func (c *Collection) Insert(item interface{}) (db.InsertResult, error)
- func (c *Collection) InsertReturning(item interface{}) error
- func (c *Collection) Name() string
- func (c *Collection) Session() db.Session
- func (c *Collection) Truncate() error
- func (c *Collection) UpdateReturning(item interface{}) error
- type CollectionCountExpectation
- type CollectionExistsExpectation
- type CollectionInsertExpectation
- type CollectionInsertReturningExpectation
- type CollectionTruncateExpectation
- type CollectionUpdateReturningExpectation
- type Result
- func (r *Result) All(slice interface{}) error
- func (r *Result) And(args ...interface{}) db.Result
- func (r *Result) Close() error
- func (r *Result) Count() (uint64, error)
- func (r *Result) Cursor(arg string) db.Result
- func (r *Result) Delete() error
- func (r *Result) Err() error
- func (r *Result) Exists() (bool, error)
- func (r *Result) ExpectAll(e *ResultAllExpectation)
- func (r *Result) ExpectAllArgs(slice interface{}, retSlice interface{}, retError error)
- func (r *Result) ExpectCount(e *ResultCountExpectation)
- func (r *Result) ExpectCountArgs(expectedResult uint64, expectedError error)
- func (r *Result) ExpectDelete(e *ResultDeleteExpectation)
- func (r *Result) ExpectDeleteArgs(retError error)
- func (r *Result) ExpectExists(e *ResultExistsExpectation)
- func (r *Result) ExpectExistsArgs(expectedResult bool, expectedError error)
- func (r *Result) ExpectOne(e *ResultOneExpectation)
- func (r *Result) ExpectOneArgs(item interface{}, retItem interface{}, retError error)
- func (r *Result) ExpectUpdate(e *ResultUpdateExpectation)
- func (r *Result) ExpectUpdateArgs(item interface{}, retError error)
- func (r *Result) GroupBy(args ...interface{}) db.Result
- func (r *Result) Limit(arg int) db.Result
- func (r *Result) Next(ptrToStruct interface{}) bool
- func (r *Result) NextPage(arg interface{}) db.Result
- func (r *Result) Offset(arg int) db.Result
- func (r *Result) One(item interface{}) error
- func (r *Result) OrderBy(args ...interface{}) db.Result
- func (r *Result) Page(arg uint) db.Result
- func (r *Result) Paginate(arg uint) db.Result
- func (r *Result) PrevPage(arg interface{}) db.Result
- func (r *Result) Select(args ...interface{}) db.Result
- func (r *Result) String() string
- func (r *Result) TotalEntries() (uint64, error)
- func (r *Result) TotalPages() (uint, error)
- func (r *Result) Update(item interface{}) error
- type ResultAllExpectation
- type ResultCountExpectation
- type ResultDeleteExpectation
- type ResultExistsExpectation
- type ResultOneExpectation
- type ResultUpdateExpectation
- type SQL
- func (s *SQL) DeleteFrom(table string) db.Deleter
- func (s *SQL) Exec(query interface{}, args ...interface{}) (sql.Result, error)
- func (s *SQL) ExecContext(ctx context.Context, query interface{}, args ...interface{}) (sql.Result, error)
- func (s *SQL) InsertInto(table string) db.Inserter
- func (s *SQL) Iterator(query interface{}, args ...interface{}) db.Iterator
- func (s *SQL) IteratorContext(ctx context.Context, query interface{}, args ...interface{}) db.Iterator
- func (s *SQL) NewIterator(rows *sql.Rows) db.Iterator
- func (s *SQL) NewIteratorContext(ctx context.Context, rows *sql.Rows) db.Iterator
- func (s *SQL) Prepare(query interface{}) (*sql.Stmt, error)
- func (s *SQL) PrepareContext(ctx context.Context, query interface{}) (*sql.Stmt, error)
- func (s *SQL) Query(query interface{}, args ...interface{}) (*sql.Rows, error)
- func (s *SQL) QueryContext(ctx context.Context, query interface{}, args ...interface{}) (*sql.Rows, error)
- func (s *SQL) QueryRow(query interface{}, args ...interface{}) (*sql.Row, error)
- func (s *SQL) QueryRowContext(ctx context.Context, query interface{}, args ...interface{}) (*sql.Row, error)
- func (s *SQL) Select(args ...interface{}) db.Selector
- func (s *SQL) SelectFrom(args ...interface{}) db.Selector
- func (s *SQL) Update(table string) db.Updater
- type Selector
- func (s *Selector) All(slice interface{}) error
- func (s *Selector) Amend(arg func(string) string) db.Selector
- func (s *Selector) And(args ...interface{}) db.Selector
- func (s *Selector) Arguments() []interface{}
- func (s *Selector) As(arg string) db.Selector
- func (s *Selector) Columns(args ...interface{}) db.Selector
- func (s *Selector) CrossJoin(args ...interface{}) db.Selector
- func (s *Selector) Distinct(args ...interface{}) db.Selector
- func (s *Selector) ExpectAll(e *SelectorAllExpectation)
- func (s *Selector) ExpectAllArgs(slice interface{}, retSlice interface{}, retError error)
- func (s *Selector) ExpectOne(e *SelectorOneExpectation)
- func (s *Selector) ExpectOneArgs(item interface{}, retItem interface{}, retError error)
- func (s *Selector) From(args ...interface{}) db.Selector
- func (s *Selector) FullJoin(args ...interface{}) db.Selector
- func (s *Selector) GroupBy(args ...interface{}) db.Selector
- func (s *Selector) Iterator() db.Iterator
- func (s *Selector) IteratorContext(ctx context.Context) db.Iterator
- func (s *Selector) Join(args ...interface{}) db.Selector
- func (s *Selector) LeftJoin(args ...interface{}) db.Selector
- func (s *Selector) Limit(arg int) db.Selector
- func (s *Selector) Offset(arg int) db.Selector
- func (s *Selector) On(args ...interface{}) db.Selector
- func (s *Selector) One(item interface{}) error
- func (s *Selector) OrderBy(args ...interface{}) db.Selector
- func (s *Selector) Paginate(uint) db.Paginator
- func (s *Selector) Prepare() (*sql.Stmt, error)
- func (s *Selector) PrepareContext(context.Context) (*sql.Stmt, error)
- func (s *Selector) Query() (*sql.Rows, error)
- func (s *Selector) QueryContext(context.Context) (*sql.Rows, error)
- func (s *Selector) QueryRow() (*sql.Row, error)
- func (s *Selector) QueryRowContext(ctx context.Context) (*sql.Row, error)
- func (s *Selector) RightJoin(args ...interface{}) db.Selector
- func (s *Selector) String() string
- func (s *Selector) Using(args ...interface{}) db.Selector
- func (s *Selector) Where(args ...interface{}) db.Selector
- type SelectorAllExpectation
- type SelectorOneExpectation
- type Session
- func (s *Session) Close() error
- func (s *Session) Collection(name string) db.Collection
- func (s *Session) Collections() ([]db.Collection, error)
- func (s *Session) ConnMaxLifetime() time.Duration
- func (s *Session) ConnectionURL() db.ConnectionURL
- func (s *Session) Context() context.Context
- func (s *Session) Delete(record db.Record) error
- func (s *Session) Driver() interface{}
- func (s *Session) ExpectDelete(e *SessionDeleteExpectation)
- func (s *Session) ExpectDeleteArgs(record db.Record, retError error)
- func (s *Session) ExpectGet(e *SessionGetExpectation)
- func (s *Session) ExpectGetArgs(record db.Record, cond interface{}, retRecord db.Record, retError error)
- func (s *Session) ExpectSave(e *SessionSaveExpectation)
- func (s *Session) ExpectSaveArgs(record db.Record, retError error)
- func (s *Session) Get(record db.Record, cond interface{}) error
- func (s *Session) MaxIdleConns() int
- func (s *Session) MaxOpenConns() int
- func (s *Session) MaxTransactionRetries() int
- func (s *Session) Name() string
- func (s *Session) Ping() error
- func (s *Session) PreparedStatementCacheEnabled() bool
- func (s *Session) Reset()
- func (s *Session) SQL() db.SQL
- func (s *Session) Save(record db.Record) error
- func (s *Session) SetConnMaxLifetime(time.Duration)
- func (s *Session) SetMaxIdleConns(int)
- func (s *Session) SetMaxOpenConns(int)
- func (s *Session) SetMaxTransactionRetries(int)
- func (s *Session) SetPreparedStatementCache(bool)
- func (s *Session) Tx(fn func(db.Session) error) error
- func (s *Session) TxContext(_ context.Context, fn func(db.Session) error, _ *sql.TxOptions) error
- func (s *Session) WithContext(ctx context.Context) db.Session
- type SessionDeleteExpectation
- type SessionGetExpectation
- type SessionSaveExpectation
Constants ¶
This section is empty.
Variables ¶
var ErrNoMatchingExpectations = errors.New("no matching expectations")
ErrNoMatchingExpectations defines the error returned when no expectations could be matched to the current action.
var ErrUnimplemented = errors.New("unimplemented")
ErrUnimplemented defines the error returned when a method is not yet implemented.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection defines an upper.io collection used in tests to simulate a database.
func (*Collection) Count ¶
func (c *Collection) Count() (uint64, error)
Count returns the first expectation from the list.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Collection) Exists ¶
func (c *Collection) Exists() (bool, error)
Exists returns the first expectation from the list.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Collection) ExpectCount ¶
func (c *Collection) ExpectCount(e *CollectionCountExpectation)
ExpectCount adds an expectation for the Count method.
func (*Collection) ExpectCountArgs ¶
func (c *Collection) ExpectCountArgs(retResult uint64, retError error)
ExpectCountArgs adds an expectation for the Count method, by separate arguments.
func (*Collection) ExpectExists ¶
func (c *Collection) ExpectExists(e *CollectionExistsExpectation)
ExpectExists adds an expectation for the Exists method.
func (*Collection) ExpectExistsArgs ¶
func (c *Collection) ExpectExistsArgs(retResult bool, retError error)
ExpectExistsArgs adds an expectation for the Exists method, by separate arguments.
func (*Collection) ExpectInsert ¶
func (c *Collection) ExpectInsert(e *CollectionInsertExpectation)
ExpectInsert adds an expectation for the Insert method.
func (*Collection) ExpectInsertArgs ¶
func (c *Collection) ExpectInsertArgs(item interface{}, retID interface{}, retError error)
ExpectInsertArgs adds an expectation for the Insert method, by separate arguments.
func (*Collection) ExpectInsertReturning ¶
func (c *Collection) ExpectInsertReturning(e *CollectionInsertReturningExpectation)
ExpectInsertReturning adds an expectation for the InsertReturning method.
func (*Collection) ExpectInsertReturningArgs ¶
func (c *Collection) ExpectInsertReturningArgs(item interface{}, retItem interface{}, retError error)
ExpectInsertReturningArgs adds an expectation for the InsertReturning method, by separate arguments.
func (*Collection) ExpectTruncate ¶
func (c *Collection) ExpectTruncate(e *CollectionTruncateExpectation)
ExpectTruncate adds an expectation for the Truncate method.
func (*Collection) ExpectTruncateArgs ¶
func (c *Collection) ExpectTruncateArgs(retError error)
ExpectTruncateArgs adds an expectation for the Truncate method, by separate arguments.
func (*Collection) ExpectUpdateReturning ¶
func (c *Collection) ExpectUpdateReturning(e *CollectionUpdateReturningExpectation)
ExpectUpdateReturning adds an expectation for the UpdateReturning method.
func (*Collection) ExpectUpdateReturningArgs ¶
func (c *Collection) ExpectUpdateReturningArgs(item interface{}, retItem interface{}, retError error)
ExpectUpdateReturningArgs adds an expectation for the UpdateReturning method, by separate arguments.
func (*Collection) Find ¶
func (c *Collection) Find(args ...interface{}) db.Result
Find creates a new test result.
func (*Collection) Insert ¶
func (c *Collection) Insert(item interface{}) (db.InsertResult, error)
Insert returns the first matching expectation from the list.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Collection) InsertReturning ¶
func (c *Collection) InsertReturning(item interface{}) error
InsertReturning returns the first matching expectation from the list.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Collection) Session ¶
func (c *Collection) Session() db.Session
Session returns the current test session.
func (*Collection) Truncate ¶
func (c *Collection) Truncate() error
Truncate returns the first expectation from the list.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Collection) UpdateReturning ¶
func (c *Collection) UpdateReturning(item interface{}) error
UpdateReturning returns the first matching expectation from the list.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
type CollectionCountExpectation ¶
CollectionCountExpectation defines the returned values for the Count method.
type CollectionExistsExpectation ¶
CollectionExistsExpectation defines the returned values for the Exists method.
type CollectionInsertExpectation ¶
type CollectionInsertExpectation struct { ExpectedItem interface{} ReturnedID interface{} ReturnedError error }
CollectionInsertExpectation defines the expected and returned values for the Insert method.
type CollectionInsertReturningExpectation ¶
type CollectionInsertReturningExpectation struct { ExpectedItem interface{} ReturnedItem interface{} ReturnedError error }
CollectionInsertReturningExpectation defines the expected and returned values for the InsertReturning method.
type CollectionTruncateExpectation ¶
type CollectionTruncateExpectation struct {
ReturnedError error
}
CollectionTruncateExpectation defines the returned values for the Truncate method.
type CollectionUpdateReturningExpectation ¶
type CollectionUpdateReturningExpectation struct { ExpectedItem interface{} ReturnedItem interface{} ReturnedError error }
CollectionUpdateReturningExpectation defines the expected and returned values for the UpdateReturning method.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result defines an upper.io result used in tests to simulate a database.
func (*Result) All ¶
All returns the first matching expectation from the list, replacing the specified slice with the returned items.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Result) And ¶
func (r *Result) And(args ...interface{}) db.Result
And adds an argument expectation to the result.
func (*Result) Count ¶
Count returns the first expectation from the list.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Result) Delete ¶
Delete returns the first matching expectation from the list.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Result) Exists ¶
Exists returns the first expectation from the list.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Result) ExpectAll ¶
func (r *Result) ExpectAll(e *ResultAllExpectation)
ExpectAll adds an expectation for the All method.
func (*Result) ExpectAllArgs ¶
ExpectAllArgs adds an expectation for the All method, by separate arguments.
func (*Result) ExpectCount ¶
func (r *Result) ExpectCount(e *ResultCountExpectation)
ExpectCount adds an expectation for the Count method.
func (*Result) ExpectCountArgs ¶
ExpectCountArgs adds an expectation for the Count method, by separate arguments.
func (*Result) ExpectDelete ¶
func (r *Result) ExpectDelete(e *ResultDeleteExpectation)
ExpectDelete adds an expectation for the Delete method.
func (*Result) ExpectDeleteArgs ¶
ExpectDeleteArgs adds an expectation for the Delete method, by separate arguments.
func (*Result) ExpectExists ¶
func (r *Result) ExpectExists(e *ResultExistsExpectation)
ExpectExists adds an expectation for the Exists method.
func (*Result) ExpectExistsArgs ¶
ExpectExistsArgs adds an expectation for the Exists method, by separate arguments.
func (*Result) ExpectOne ¶
func (r *Result) ExpectOne(e *ResultOneExpectation)
ExpectOne adds an expectation for the One method.
func (*Result) ExpectOneArgs ¶
ExpectOneArgs adds an expectation for the One method, by separate arguments.
func (*Result) ExpectUpdate ¶
func (r *Result) ExpectUpdate(e *ResultUpdateExpectation)
ExpectUpdate adds an expectation for the Update method.
func (*Result) ExpectUpdateArgs ¶
ExpectUpdateArgs adds an expectation for the Update method, by separate arguments.
func (*Result) GroupBy ¶
func (r *Result) GroupBy(args ...interface{}) db.Result
GroupBy adds an argument expectation to the result.
func (*Result) NextPage ¶
func (r *Result) NextPage(arg interface{}) db.Result
NextPage adds an argument expectation to the result.
func (*Result) One ¶
One returns the first matching expectation from the list, replacing the specified item with the returned one.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Result) OrderBy ¶
func (r *Result) OrderBy(args ...interface{}) db.Result
OrderBy adds an argument expectation to the result.
func (*Result) PrevPage ¶
func (r *Result) PrevPage(arg interface{}) db.Result
PrevPage adds an argument expectation to the result.
func (*Result) Select ¶
func (r *Result) Select(args ...interface{}) db.Result
Select adds an argument expectation to the result.
func (*Result) TotalEntries ¶
TotalEntries is not implemented yet.
func (*Result) TotalPages ¶
TotalPages is not implemented yet.
type ResultAllExpectation ¶
type ResultAllExpectation struct { ExpectedSlice interface{} ReturnedSlice interface{} ReturnedError error // contains filtered or unexported fields }
ResultAllExpectation defines the expected and returned values for the All method.
type ResultCountExpectation ¶
type ResultCountExpectation struct { ReturnedResult uint64 ReturnedError error // contains filtered or unexported fields }
ResultCountExpectation defines the returned values for the Count method.
type ResultDeleteExpectation ¶
type ResultDeleteExpectation struct { ReturnedError error // contains filtered or unexported fields }
ResultDeleteExpectation defines the returned values for the Delete method.
type ResultExistsExpectation ¶
type ResultExistsExpectation struct { ReturnedResult bool ReturnedError error // contains filtered or unexported fields }
ResultExistsExpectation defines the returned values for the Exists method.
type ResultOneExpectation ¶
type ResultOneExpectation struct { ExpectedItem interface{} ReturnedItem interface{} ReturnedError error // contains filtered or unexported fields }
ResultOneExpectation defines the expected and returned values for the One method.
type ResultUpdateExpectation ¶
type ResultUpdateExpectation struct { ExpectedItem interface{} ReturnedError error // contains filtered or unexported fields }
ResultUpdateExpectation defines the expected and returned values for the Update method.
type SQL ¶
type SQL struct {
// contains filtered or unexported fields
}
SQL defines an upper.io sql object used in tests to simulate a database.
func (*SQL) DeleteFrom ¶
DeleteFrom is not implemented yet.
func (*SQL) ExecContext ¶
func (s *SQL) ExecContext(ctx context.Context, query interface{}, args ...interface{}) (sql.Result, error)
ExecContext is not implemented yet.
func (*SQL) InsertInto ¶
InsertInto is not implemented yet.
func (*SQL) Iterator ¶
func (s *SQL) Iterator(query interface{}, args ...interface{}) db.Iterator
Iterator is not implemented yet.
func (*SQL) IteratorContext ¶
func (s *SQL) IteratorContext(ctx context.Context, query interface{}, args ...interface{}) db.Iterator
IteratorContext is not implemented yet.
func (*SQL) NewIterator ¶
NewIterator is not implemented yet.
func (*SQL) NewIteratorContext ¶
NewIteratorContext is not implemented yet.
func (*SQL) PrepareContext ¶
PrepareContext is not implemented yet.
func (*SQL) QueryContext ¶
func (s *SQL) QueryContext(ctx context.Context, query interface{}, args ...interface{}) (*sql.Rows, error)
QueryContext is not implemented yet.
func (*SQL) QueryRowContext ¶
func (s *SQL) QueryRowContext(ctx context.Context, query interface{}, args ...interface{}) (*sql.Row, error)
QueryRowContext is not implemented yet.
func (*SQL) Select ¶
func (s *SQL) Select(args ...interface{}) db.Selector
Select creates a new test selector.
func (*SQL) SelectFrom ¶
func (s *SQL) SelectFrom(args ...interface{}) db.Selector
SelectFrom creates a new test selector.
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector represents a SELECT statement.
func (*Selector) All ¶
All returns the first matching expectation from the list, replacing the specified slice with the returned items.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Selector) And ¶
func (s *Selector) And(args ...interface{}) db.Selector
And adds an argument expectation to the selector.
func (*Selector) Arguments ¶
func (s *Selector) Arguments() []interface{}
Arguments is not implemented yet.
func (*Selector) Columns ¶
func (s *Selector) Columns(args ...interface{}) db.Selector
Columns adds an argument expectation to the selector.
func (*Selector) CrossJoin ¶
func (s *Selector) CrossJoin(args ...interface{}) db.Selector
CrossJoin adds an argument expectation to the selector.
func (*Selector) Distinct ¶
func (s *Selector) Distinct(args ...interface{}) db.Selector
Distinct adds an argument expectation to the selector.
func (*Selector) ExpectAll ¶
func (s *Selector) ExpectAll(e *SelectorAllExpectation)
ExpectAll adds an expectation for the All method.
func (*Selector) ExpectAllArgs ¶
ExpectAllArgs adds an expectation for the All method, by separate arguments.
func (*Selector) ExpectOne ¶
func (s *Selector) ExpectOne(e *SelectorOneExpectation)
ExpectOne adds an expectation for the One method.
func (*Selector) ExpectOneArgs ¶
ExpectOneArgs adds an expectation for the One method, by separate arguments.
func (*Selector) From ¶
func (s *Selector) From(args ...interface{}) db.Selector
From adds an argument expectation to the selector.
func (*Selector) FullJoin ¶
func (s *Selector) FullJoin(args ...interface{}) db.Selector
FullJoin adds an argument expectation to the selector.
func (*Selector) GroupBy ¶
func (s *Selector) GroupBy(args ...interface{}) db.Selector
GroupBy adds an argument expectation to the selector.
func (*Selector) Iterator ¶
func (s *Selector) Iterator() db.Iterator
Iterator is not implemented yet.
func (*Selector) IteratorContext ¶
IteratorContext is not implemented yet.
func (*Selector) Join ¶
func (s *Selector) Join(args ...interface{}) db.Selector
Join adds an argument expectation to the selector.
func (*Selector) LeftJoin ¶
func (s *Selector) LeftJoin(args ...interface{}) db.Selector
LeftJoin adds an argument expectation to the selector.
func (*Selector) On ¶
func (s *Selector) On(args ...interface{}) db.Selector
On adds an argument expectation to the selector.
func (*Selector) One ¶
One returns the first matching expectation from the list, replacing the specified item with the returned one.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Selector) OrderBy ¶
func (s *Selector) OrderBy(args ...interface{}) db.Selector
OrderBy adds an argument expectation to the selector.
func (*Selector) PrepareContext ¶
PrepareContext is not implemented yet.
func (*Selector) QueryContext ¶
QueryContext is not implemented yet.
func (*Selector) QueryRowContext ¶
QueryRowContext is not implemented yet.
func (*Selector) RightJoin ¶
func (s *Selector) RightJoin(args ...interface{}) db.Selector
RightJoin adds an argument expectation to the selector.
type SelectorAllExpectation ¶
type SelectorAllExpectation struct { ExpectedSlice interface{} ReturnedSlice interface{} ReturnedError error // contains filtered or unexported fields }
SelectorAllExpectation defines the expected and returned values for the All method.
type SelectorOneExpectation ¶
type SelectorOneExpectation struct { ExpectedItem interface{} ReturnedItem interface{} ReturnedError error // contains filtered or unexported fields }
SelectorOneExpectation defines the expected and returned values for the One method.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session defines an upper.io session used in tests to simulate a database.
func (*Session) Collection ¶
Collection returns the test collection by the specified name, creating it if needed.
func (*Session) Collections ¶
Collections is not implemented yet.
func (*Session) ConnMaxLifetime ¶
ConnMaxLifetime does nothing and always returns one second.
func (*Session) ConnectionURL ¶
func (s *Session) ConnectionURL() db.ConnectionURL
ConnectionURL does nothing.
func (*Session) Delete ¶
Delete returns the first matching expectation from the list.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Session) Driver ¶
func (s *Session) Driver() interface{}
Driver does nothing and always returns nil.
func (*Session) ExpectDelete ¶
func (s *Session) ExpectDelete(e *SessionDeleteExpectation)
ExpectDelete adds an expectation for the Delete method.
func (*Session) ExpectDeleteArgs ¶
ExpectDeleteArgs adds an expectation for the Delete method, by separate arguments.
func (*Session) ExpectGet ¶
func (s *Session) ExpectGet(e *SessionGetExpectation)
ExpectGet adds an expectation for the Get method.
func (*Session) ExpectGetArgs ¶
func (s *Session) ExpectGetArgs(record db.Record, cond interface{}, retRecord db.Record, retError error)
ExpectGetArgs adds an expectation for the Get method, by separate arguments.
func (*Session) ExpectSave ¶
func (s *Session) ExpectSave(e *SessionSaveExpectation)
ExpectSave adds an expectation for the Save method.
func (*Session) ExpectSaveArgs ¶
ExpectSaveArgs adds an expectation for the Save method, by separate arguments.
func (*Session) Get ¶
Get tries to find an expectation, matching against both record and cond arguments.
If a match is found, record will be replaced with the match's ReturnedRecord, and ReturnedError will be returned.
getExpt := &testadapter.SessionGetExpectation{ ExpectedRecord: &record{}, ExpectedCond: db.Cond{"id": 1}, ReturnedRecord: &record{ID: 1}, ReturnedError: nil, } sess := testadapter.NewSession(t) sess.ExpectGet(getExpt)
With the previous test setup, the following code ends up with rec == &record{ID: 1} and err nil:
rec := new(record) err := sess.Get(rec, db.Cond{"id": 1})
If no matches are found, this function panics with an ErrNoMatchingExpectations error.
func (*Session) MaxIdleConns ¶
MaxIdleConns does nothing and always returns 0.
func (*Session) MaxOpenConns ¶
MaxOpenConns does nothing and always returns 0.
func (*Session) MaxTransactionRetries ¶
MaxTransactionRetries does nothing and always returns 0.
func (*Session) PreparedStatementCacheEnabled ¶
PreparedStatementCacheEnabled does nothing and always returns false.
func (*Session) SQL ¶
func (s *Session) SQL() db.SQL
SQL returns a special interface for SQL databases.
func (*Session) Save ¶
Save returns the first matching expectation from the list.
This function panics with an ErrNoMatchingExpectations error if there are no such expectations.
func (*Session) SetConnMaxLifetime ¶
SetConnMaxLifetime does nothing.
func (*Session) SetMaxIdleConns ¶
SetMaxIdleConns does nothing.
func (*Session) SetMaxOpenConns ¶
SetMaxOpenConns does nothing.
func (*Session) SetMaxTransactionRetries ¶
SetMaxTransactionRetries does nothing.
func (*Session) SetPreparedStatementCache ¶
SetPreparedStatementCache does nothing.
func (*Session) WithContext ¶
WithContext does nothing and simply returns the current session.
type SessionDeleteExpectation ¶
type SessionDeleteExpectation struct { ExpectedRecord db.Record ReturnedError error }
SessionDeleteExpectation defines the expected and returned values for the Delete method.
type SessionGetExpectation ¶
type SessionGetExpectation struct { ExpectedRecord db.Record ExpectedCond interface{} ReturnedRecord db.Record ReturnedError error }
SessionGetExpectation defines the expected and returned values for the Get method.
type SessionSaveExpectation ¶
type SessionSaveExpectation struct { ExpectedRecord db.Record ReturnedError error }
SessionSaveExpectation defines the expected and returned values for the Save method.