Documentation ¶
Overview ¶
Package mock provides minimal mocks for kivik driver interfaces. It is used internally in Kivik for testing.
Index ¶
- Constants
- type AttachmentMetaGetter
- type Attachments
- type Bookmarker
- type BulkDocer
- type BulkGetter
- type Changes
- type Client
- func (c *Client) AllDBs(ctx context.Context, opts driver.Options) ([]string, error)
- func (c *Client) CreateDB(ctx context.Context, dbname string, opts driver.Options) error
- func (c *Client) DB(dbname string, opts driver.Options) (driver.DB, error)
- func (c *Client) DBExists(ctx context.Context, dbname string, opts driver.Options) (bool, error)
- func (c *Client) DestroyDB(ctx context.Context, dbname string, opts driver.Options) error
- func (c *Client) Version(ctx context.Context) (*driver.Version, error)
- type ClientCloser
- type ClientReplicator
- type Cluster
- type Configer
- func (c *Configer) Config(ctx context.Context, node string) (driver.Config, error)
- func (c *Configer) ConfigSection(ctx context.Context, node, section string) (driver.ConfigSection, error)
- func (c *Configer) ConfigValue(ctx context.Context, node, section, key string) (string, error)
- func (c *Configer) DeleteConfigKey(ctx context.Context, node, section, key string) (string, error)
- func (c *Configer) SetConfigValue(ctx context.Context, node, section, key, value string) (string, error)
- type Copier
- type DB
- func (db *DB) AllDocs(ctx context.Context, options driver.Options) (driver.Rows, error)
- func (db *DB) Changes(ctx context.Context, opts driver.Options) (driver.Changes, error)
- func (db *DB) Close() error
- func (db *DB) Compact(ctx context.Context) error
- func (db *DB) CompactView(ctx context.Context, docID string) error
- func (db *DB) CreateDoc(ctx context.Context, doc interface{}, opts driver.Options) (string, string, error)
- func (db *DB) Delete(ctx context.Context, docID string, opts driver.Options) (string, error)
- func (db *DB) DeleteAttachment(ctx context.Context, docID, filename string, opts driver.Options) (string, error)
- func (db *DB) Get(ctx context.Context, docID string, opts driver.Options) (*driver.Document, error)
- func (db *DB) GetAttachment(ctx context.Context, docID, filename string, opts driver.Options) (*driver.Attachment, error)
- func (db *DB) Put(ctx context.Context, docID string, doc interface{}, opts driver.Options) (string, error)
- func (db *DB) PutAttachment(ctx context.Context, docID string, att *driver.Attachment, opts driver.Options) (string, error)
- func (db *DB) Query(ctx context.Context, ddoc, view string, opts driver.Options) (driver.Rows, error)
- func (db *DB) Stats(ctx context.Context) (*driver.DBStats, error)
- func (db *DB) ViewCleanup(ctx context.Context) error
- type DBUpdater
- type DBUpdates
- type DBsStatser
- type DesignDocer
- type Driver
- type Finder
- func (db *Finder) CreateIndex(ctx context.Context, ddoc, name string, index interface{}, ...) error
- func (db *Finder) DeleteIndex(ctx context.Context, ddoc, name string, opts driver.Options) error
- func (db *Finder) Explain(ctx context.Context, query interface{}, opts driver.Options) (*driver.QueryPlan, error)
- func (db *Finder) Find(ctx context.Context, query interface{}, opts driver.Options) (driver.Rows, error)
- func (db *Finder) GetIndexes(ctx context.Context, opts driver.Options) ([]driver.Index, error)
- type Flusher
- type LocalDocer
- type OpenRever
- type PartitionedDB
- type Pinger
- type Purger
- type Replication
- func (r *Replication) Delete(ctx context.Context) error
- func (r *Replication) EndTime() time.Time
- func (r *Replication) Err() error
- func (r *Replication) ReplicationID() string
- func (r *Replication) Source() string
- func (r *Replication) StartTime() time.Time
- func (r *Replication) State() string
- func (r *Replication) Target() string
- func (r *Replication) Update(ctx context.Context, rep *driver.ReplicationInfo) error
- type RevGetter
- type RevsDiffer
- type Rows
- type RowsWarner
- type SecurityDB
- type Sessioner
Constants ¶
const NilOption nilOption = false
NilOption is a nil option.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttachmentMetaGetter ¶
type AttachmentMetaGetter struct { *DB GetAttachmentMetaFunc func(ctx context.Context, docID, filename string, options driver.Options) (*driver.Attachment, error) }
AttachmentMetaGetter mocks a driver.DB and driver.AttachmentMetaGetter
func (*AttachmentMetaGetter) GetAttachmentMeta ¶
func (db *AttachmentMetaGetter) GetAttachmentMeta(ctx context.Context, docID, filename string, options driver.Options) (*driver.Attachment, error)
GetAttachmentMeta calls db.GetAttachmentMetaFunc
type Attachments ¶
type Attachments struct { // ID identifies a specific Attachments instance ID string NextFunc func(*driver.Attachment) error CloseFunc func() error }
Attachments mocks driver.Attachments
func (*Attachments) Next ¶
func (a *Attachments) Next(att *driver.Attachment) error
Next calls a.NextFunc
type Bookmarker ¶
Bookmarker wraps driver.Bookmarker
type BulkDocer ¶
type BulkDocer struct { *DB BulkDocsFunc func(ctx context.Context, docs []interface{}, options driver.Options) ([]driver.BulkResult, error) }
BulkDocer mocks a driver.DB and driver.BulkDocer
type BulkGetter ¶
type BulkGetter struct { *DB BulkGetFunc func(context.Context, []driver.BulkGetReference, driver.Options) (driver.Rows, error) }
BulkGetter mocks a driver.DB and driver.BulkGetter
type Changes ¶
type Changes struct { NextFunc func(*driver.Change) error CloseFunc func() error LastSeqFunc func() string PendingFunc func() int64 ETagFunc func() string }
Changes mocks driver.Changes
type Client ¶
type Client struct { // ID identifies a specific Client instance ID string AllDBsFunc func(context.Context, driver.Options) ([]string, error) CreateDBFunc func(context.Context, string, driver.Options) error DBFunc func(string, driver.Options) (driver.DB, error) DBExistsFunc func(context.Context, string, driver.Options) (bool, error) DestroyDBFunc func(context.Context, string, driver.Options) error VersionFunc func(context.Context) (*driver.Version, error) }
Client mocks driver.Client
type ClientCloser ¶
ClientCloser mocks driver.Client and driver.ClientCloser
type ClientReplicator ¶
type ClientReplicator struct { *Client GetReplicationsFunc func(context.Context, driver.Options) ([]driver.Replication, error) ReplicateFunc func(context.Context, string, string, driver.Options) (driver.Replication, error) }
ClientReplicator mocks driver.Client and driver.ClientReplicator
func (*ClientReplicator) GetReplications ¶
func (c *ClientReplicator) GetReplications(ctx context.Context, opts driver.Options) ([]driver.Replication, error)
GetReplications calls c.GetReplicationsFunc
type Cluster ¶
type Cluster struct { *Client ClusterStatusFunc func(context.Context, driver.Options) (string, error) ClusterSetupFunc func(context.Context, interface{}) error MembershipFunc func(context.Context) (*driver.ClusterMembership, error) }
Cluster mocks driver.Client and driver.Cluster
func (*Cluster) ClusterSetup ¶
ClusterSetup calls c.ClusterSetupFunc
func (*Cluster) ClusterStatus ¶
ClusterStatus calls c.ClusterStatusFunc
func (*Cluster) Membership ¶
Membership calls c.MembershipFunc
type Configer ¶
type Configer struct { *Client ConfigFunc func(context.Context, string) (driver.Config, error) ConfigSectionFunc func(context.Context, string, string) (driver.ConfigSection, error) ConfigValueFunc func(context.Context, string, string, string) (string, error) SetConfigValueFunc func(context.Context, string, string, string, string) (string, error) DeleteConfigKeyFunc func(context.Context, string, string, string) (string, error) }
Configer mocks driver.Client and driver.Configer
func (*Configer) ConfigSection ¶
func (c *Configer) ConfigSection(ctx context.Context, node, section string) (driver.ConfigSection, error)
ConfigSection calls c.ConfSectionFunc
func (*Configer) ConfigValue ¶
ConfigValue calls c.ConfigValueFunc
func (*Configer) DeleteConfigKey ¶
DeleteConfigKey calls c.DeleteConfigKeyFunc
type Copier ¶
type Copier struct { *DB CopyFunc func(context.Context, string, string, driver.Options) (string, error) }
Copier mocks a driver.DB and driver.Copier.
type DB ¶
type DB struct { // ID is a unique identifier for the DB instance. ID string AllDocsFunc func(ctx context.Context, options driver.Options) (driver.Rows, error) GetFunc func(ctx context.Context, docID string, options driver.Options) (*driver.Document, error) CreateDocFunc func(ctx context.Context, doc interface{}, options driver.Options) (docID, rev string, err error) PutFunc func(ctx context.Context, docID string, doc interface{}, options driver.Options) (rev string, err error) DeleteFunc func(ctx context.Context, docID string, options driver.Options) (newRev string, err error) StatsFunc func(ctx context.Context) (*driver.DBStats, error) CompactFunc func(ctx context.Context) error CompactViewFunc func(ctx context.Context, ddocID string) error ViewCleanupFunc func(ctx context.Context) error ChangesFunc func(ctx context.Context, options driver.Options) (driver.Changes, error) PutAttachmentFunc func(ctx context.Context, docID string, att *driver.Attachment, options driver.Options) (newRev string, err error) GetAttachmentFunc func(ctx context.Context, docID, filename string, options driver.Options) (*driver.Attachment, error) DeleteAttachmentFunc func(ctx context.Context, docID, filename string, options driver.Options) (newRev string, err error) QueryFunc func(context.Context, string, string, driver.Options) (driver.Rows, error) CloseFunc func() error }
DB mocks a driver.DB
func (*DB) CompactView ¶
CompactView calls db.CompactViewFunc
func (*DB) CreateDoc ¶
func (db *DB) CreateDoc(ctx context.Context, doc interface{}, opts driver.Options) (string, string, error)
CreateDoc calls db.CreateDocFunc
func (*DB) DeleteAttachment ¶
func (db *DB) DeleteAttachment(ctx context.Context, docID, filename string, opts driver.Options) (string, error)
DeleteAttachment calls db.DeleteAttachmentFunc
func (*DB) GetAttachment ¶
func (db *DB) GetAttachment(ctx context.Context, docID, filename string, opts driver.Options) (*driver.Attachment, error)
GetAttachment calls db.GetAttachmentFunc
func (*DB) Put ¶
func (db *DB) Put(ctx context.Context, docID string, doc interface{}, opts driver.Options) (string, error)
Put calls db.PutFunc
func (*DB) PutAttachment ¶
func (db *DB) PutAttachment(ctx context.Context, docID string, att *driver.Attachment, opts driver.Options) (string, error)
PutAttachment calls db.PutAttachmentFunc
func (*DB) Query ¶
func (db *DB) Query(ctx context.Context, ddoc, view string, opts driver.Options) (driver.Rows, error)
Query calls db.QueryFunc.
type DBUpdater ¶
type DBUpdater struct { *Client DBUpdatesFunc func(context.Context, driver.Options) (driver.DBUpdates, error) }
DBUpdater mocks driver.Client and driver.DBUpdater
type DBUpdates ¶
type DBUpdates struct { // ID identifies a specific DBUpdates instance. ID string NextFunc func(*driver.DBUpdate) error CloseFunc func() error }
DBUpdates mocks driver.DBUpdates
type DBsStatser ¶
type DBsStatser struct { *Client DBsStatsFunc func(context.Context, []string) ([]*driver.DBStats, error) }
DBsStatser mocks driver.Client and driver.DBsStatser
type DesignDocer ¶
type DesignDocer struct { *DB DesignDocsFunc func(context.Context, driver.Options) (driver.Rows, error) }
DesignDocer mocks a driver.DB and driver.DesignDocer
func (*DesignDocer) DesignDocs ¶
DesignDocs calls db.DesignDocsFunc
type Driver ¶
type Driver struct {
NewClientFunc func(name string, options driver.Options) (driver.Client, error)
}
Driver mocks a Kivik Driver.
type Finder ¶
type Finder struct { *DB CreateIndexFunc func(context.Context, string, string, interface{}, driver.Options) error DeleteIndexFunc func(context.Context, string, string, driver.Options) error FindFunc func(context.Context, interface{}, driver.Options) (driver.Rows, error) GetIndexesFunc func(context.Context, driver.Options) ([]driver.Index, error) ExplainFunc func(context.Context, interface{}, driver.Options) (*driver.QueryPlan, error) }
Finder mocks a driver.DB and driver.Finder
func (*Finder) CreateIndex ¶
func (db *Finder) CreateIndex(ctx context.Context, ddoc, name string, index interface{}, options driver.Options) error
CreateIndex calls db.CreateIndexFunc
func (*Finder) DeleteIndex ¶
DeleteIndex calls db.DeleteIndexFunc
func (*Finder) Explain ¶
func (db *Finder) Explain(ctx context.Context, query interface{}, opts driver.Options) (*driver.QueryPlan, error)
Explain calls db.ExplainFunc
type LocalDocer ¶
type LocalDocer struct { *DB LocalDocsFunc func(context.Context, driver.Options) (driver.Rows, error) }
LocalDocer mocks a driver.DB and driver.DesignDocer
type OpenRever ¶
type OpenRever struct { *DB OpenRevsFunc func(context.Context, string, []string, driver.Options) (driver.Rows, error) }
OpenRever mocks a driver.DB and driver.OpenRever.
type PartitionedDB ¶
type PartitionedDB struct { *DB PartitionStatsFunc func(context.Context, string) (*driver.PartitionStats, error) }
PartitionedDB mocks a driver.DB and a driver.PartitionedDB.
func (*PartitionedDB) PartitionStats ¶
func (db *PartitionedDB) PartitionStats(ctx context.Context, name string) (*driver.PartitionStats, error)
PartitionStats calls db.PartitionStatsFunc.
type Purger ¶
type Purger struct { *DB PurgeFunc func(context.Context, map[string][]string) (*driver.PurgeResult, error) }
Purger mocks a driver.DB and driver.Purger
type Replication ¶
type Replication struct { // ID identifies a specific Replication instance ID string DeleteFunc func(context.Context) error StartTimeFunc func() time.Time EndTimeFunc func() time.Time ErrFunc func() error ReplicationIDFunc func() string SourceFunc func() string TargetFunc func() string StateFunc func() string UpdateFunc func(context.Context, *driver.ReplicationInfo) error }
Replication mocks driver.Replication
func (*Replication) Delete ¶
func (r *Replication) Delete(ctx context.Context) error
Delete calls r.DeleteFunc
func (*Replication) ReplicationID ¶
func (r *Replication) ReplicationID() string
ReplicationID calls r.ReplicatoinIDFunc
func (*Replication) Source ¶
func (r *Replication) Source() string
Source calls r.SourceFunc or returns a default value if SourceFunc is nil
func (*Replication) StartTime ¶
func (r *Replication) StartTime() time.Time
StartTime calls r.StartTimeFunc
func (*Replication) Target ¶
func (r *Replication) Target() string
Target calls r.TargetFunc or returns a default if TargetFunc is nil
func (*Replication) Update ¶
func (r *Replication) Update(ctx context.Context, rep *driver.ReplicationInfo) error
Update calls r.UpdateFunc
type RevGetter ¶
type RevGetter struct { *DB GetRevFunc func(context.Context, string, driver.Options) (string, error) }
RevGetter mocks a driver.DB and driver.RevGetter
type RevsDiffer ¶
type RevsDiffer struct { *BulkDocer RevsDiffFunc func(context.Context, interface{}) (driver.Rows, error) }
RevsDiffer mocks a driver.DB and driver.RevsDiffer.
type Rows ¶
type Rows struct { // ID identifies a specific Rows instance. ID string CloseFunc func() error NextFunc func(*driver.Row) error OffsetFunc func() int64 TotalRowsFunc func() int64 UpdateSeqFunc func() string }
Rows mocks driver.Rows
type RowsWarner ¶
RowsWarner wraps driver.RowsWarner
type SecurityDB ¶
type SecurityDB struct { DB SecurityFunc func(ctx context.Context) (*driver.Security, error) SetSecurityFunc func(ctx context.Context, security *driver.Security) error }
SecurityDB is a stub for a driver.SecurityDB.
func (*SecurityDB) SetSecurity ¶
SetSecurity calls db.SetSecurityFunc