Documentation

Overview

Package mock provides minimal mocks for kivik driver interfaces. It is used internally in Kivik for testing.

Index

Constants

This section is empty.

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 map[string]interface{}) (*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 map[string]interface{}) (*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) Close

func (a *Attachments) Close() error

Close calls a.CloseFunc

func (*Attachments) Next

func (a *Attachments) Next(att *driver.Attachment) error

Next calls a.NextFunc

type Authenticator

type Authenticator struct {
	*Client
	AuthenticateFunc func(context.Context, interface{}) error
}

Authenticator mocks driver.Client and driver.Authenticator

func (*Authenticator) Authenticate

func (c *Authenticator) Authenticate(ctx context.Context, a interface{}) error

Authenticate calls c.AuthenticateFunc

type Bookmarker

type Bookmarker struct {
	*Rows
	BookmarkFunc func() string
}

Bookmarker wraps driver.Bookmarker

func (*Bookmarker) Bookmark

func (r *Bookmarker) Bookmark() string

Bookmark calls r.BookmarkFunc

type BulkDocer

type BulkDocer struct {
	*DB
	BulkDocsFunc func(ctx context.Context, docs []interface{}, options map[string]interface{}) (driver.BulkResults, error)
}

BulkDocer mocks a driver.DB and driver.BulkDocer

func (*BulkDocer) BulkDocs

func (db *BulkDocer) BulkDocs(ctx context.Context, docs []interface{}, options map[string]interface{}) (driver.BulkResults, error)

BulkDocs calls db.BulkDocsFunc

type BulkGetter

type BulkGetter struct {
	*DB
	BulkGetFunc func(context.Context, []driver.BulkGetReference, map[string]interface{}) (driver.Rows, error)
}

BulkGetter mocks a driver.DB and driver.BulkGetter

func (*BulkGetter) BulkGet

func (db *BulkGetter) BulkGet(ctx context.Context, docs []driver.BulkGetReference, opts map[string]interface{}) (driver.Rows, error)

BulkGet calls db.BulkGetFunc

type BulkResults

type BulkResults struct {
	// ID identifies a specific BulkResults instance
	ID        string
	NextFunc  func(*driver.BulkResult) error
	CloseFunc func() error
}

BulkResults mocks driver.BulkResults

func (*BulkResults) Close

func (r *BulkResults) Close() error

Close calls r.CloseFunc

func (*BulkResults) Next

func (r *BulkResults) Next(result *driver.BulkResult) error

Next calls r.NextFunc

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

func (*Changes) Close

func (c *Changes) Close() error

Close calls c.CloseFunc

func (*Changes) ETag

func (c *Changes) ETag() string

ETag calls c.ETagFunc

func (*Changes) LastSeq

func (c *Changes) LastSeq() string

LastSeq calls c.LastSeqFunc

func (*Changes) Next

func (c *Changes) Next(change *driver.Change) error

Next calls c.NextFunc

func (*Changes) Pending

func (c *Changes) Pending() int64

Pending calls c.PendingFunc

type Client

type Client struct {
	// ID identifies a specific Client instance
	ID            string
	AllDBsFunc    func(context.Context, map[string]interface{}) ([]string, error)
	CreateDBFunc  func(context.Context, string, map[string]interface{}) error
	DBFunc        func(context.Context, string, map[string]interface{}) (driver.DB, error)
	DBExistsFunc  func(context.Context, string, map[string]interface{}) (bool, error)
	DestroyDBFunc func(context.Context, string, map[string]interface{}) error
	VersionFunc   func(context.Context) (*driver.Version, error)
}

Client mocks driver.Client

func (*Client) AllDBs

func (c *Client) AllDBs(ctx context.Context, opts map[string]interface{}) ([]string, error)

AllDBs calls c.AllDBsFunc

func (*Client) CreateDB

func (c *Client) CreateDB(ctx context.Context, dbname string, opts map[string]interface{}) error

CreateDB calls c.CreateDBFunc

func (*Client) DB

func (c *Client) DB(ctx context.Context, dbname string, opts map[string]interface{}) (driver.DB, error)

DB calls c.DBFunc

func (*Client) DBExists

func (c *Client) DBExists(ctx context.Context, dbname string, opts map[string]interface{}) (bool, error)

DBExists calls c.DBExistsFunc

func (*Client) DestroyDB

func (c *Client) DestroyDB(ctx context.Context, dbname string, opts map[string]interface{}) error

DestroyDB calls c.DestroyDBFunc

func (*Client) Version

func (c *Client) Version(ctx context.Context) (*driver.Version, error)

Version calls c.VersionFunc

type ClientCloser

type ClientCloser struct {
	*Client
	CloseFunc func(context.Context) error
}

ClientCloser mocks driver.Client and driver.ClientCloser

func (*ClientCloser) Close

func (c *ClientCloser) Close(ctx context.Context) error

Close calls c.CloseFunc

type ClientReplicator

type ClientReplicator struct {
	*Client
	GetReplicationsFunc func(context.Context, map[string]interface{}) ([]driver.Replication, error)
	ReplicateFunc       func(context.Context, string, string, map[string]interface{}) (driver.Replication, error)
}

ClientReplicator mocks driver.Client and driver.ClientReplicator

func (*ClientReplicator) GetReplications

func (c *ClientReplicator) GetReplications(ctx context.Context, opts map[string]interface{}) ([]driver.Replication, error)

GetReplications calls c.GetReplicationsFunc

func (*ClientReplicator) Replicate

func (c *ClientReplicator) Replicate(ctx context.Context, target, source string, opts map[string]interface{}) (driver.Replication, error)

Replicate calls c.ReplicateFunc

type Cluster

type Cluster struct {
	*Client
	ClusterStatusFunc func(context.Context, map[string]interface{}) (string, error)
	ClusterSetupFunc  func(context.Context, interface{}) error
}

Cluster mocks driver.Client and driver.Cluster

func (*Cluster) ClusterSetup

func (c *Cluster) ClusterSetup(ctx context.Context, action interface{}) error

ClusterSetup calls c.ClusterSetupFunc

func (*Cluster) ClusterStatus

func (c *Cluster) ClusterStatus(ctx context.Context, options map[string]interface{}) (string, error)

ClusterStatus calls c.ClusterStatusFunc

type Cluster2

type Cluster2 struct {
	*Client
	MembershipFunc func(context.Context) (*driver.ClusterMembership, error)
}

Cluster2 mocks driver.Client and driver.Cluster2

func (*Cluster2) Membership

func (c *Cluster2) Membership(ctx context.Context) (*driver.ClusterMembership, error)

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) Config

func (c *Configer) Config(ctx context.Context, node string) (driver.Config, error)

Config calls c.ConfigFunc

func (*Configer) ConfigSection

func (c *Configer) ConfigSection(ctx context.Context, node, section string) (driver.ConfigSection, error)

ConfigSection calls c.ConfSectionFunc

func (*Configer) ConfigValue

func (c *Configer) ConfigValue(ctx context.Context, node, section, key string) (string, error)

ConfigValue calls c.ConfigValueFunc

func (*Configer) DeleteConfigKey

func (c *Configer) DeleteConfigKey(ctx context.Context, node, section, key string) (string, error)

DeleteConfigKey calls c.DeleteConfigKeyFunc

func (*Configer) SetConfigValue

func (c *Configer) SetConfigValue(ctx context.Context, node, section, key, value string) (string, error)

SetConfigValue calls c.SetConfigValueFunc

type Copier

type Copier struct {
	*DB
	CopyFunc func(context.Context, string, string, map[string]interface{}) (string, error)
}

Copier mocks a driver.DB and driver.Copier.

func (*Copier) Copy

func (db *Copier) Copy(ctx context.Context, target, source string, options map[string]interface{}) (string, error)

Copy calls db.CopyFunc

type DB

type DB struct {
	// ID is a unique identifier for the DB instance.
	ID                   string
	AllDocsFunc          func(ctx context.Context, options map[string]interface{}) (driver.Rows, error)
	GetFunc              func(ctx context.Context, docID string, options map[string]interface{}) (*driver.Document, error)
	CreateDocFunc        func(ctx context.Context, doc interface{}, options map[string]interface{}) (docID, rev string, err error)
	PutFunc              func(ctx context.Context, docID string, doc interface{}, options map[string]interface{}) (rev string, err error)
	DeleteFunc           func(ctx context.Context, docID, rev string, options map[string]interface{}) (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
	SecurityFunc         func(ctx context.Context) (*driver.Security, error)
	SetSecurityFunc      func(ctx context.Context, security *driver.Security) error
	ChangesFunc          func(ctx context.Context, options map[string]interface{}) (driver.Changes, error)
	PutAttachmentFunc    func(ctx context.Context, docID, rev string, att *driver.Attachment, options map[string]interface{}) (newRev string, err error)
	GetAttachmentFunc    func(ctx context.Context, docID, filename string, options map[string]interface{}) (*driver.Attachment, error)
	DeleteAttachmentFunc func(ctx context.Context, docID, rev, filename string, options map[string]interface{}) (newRev string, err error)
	QueryFunc            func(context.Context, string, string, map[string]interface{}) (driver.Rows, error)
}

DB mocks a driver.DB

func (*DB) AllDocs

func (db *DB) AllDocs(ctx context.Context, options map[string]interface{}) (driver.Rows, error)

AllDocs calls db.AllDocsFunc

func (*DB) Changes

func (db *DB) Changes(ctx context.Context, opts map[string]interface{}) (driver.Changes, error)

Changes calls db.ChangesFunc

func (*DB) Compact

func (db *DB) Compact(ctx context.Context) error

Compact calls db.CompactFunc

func (*DB) CompactView

func (db *DB) CompactView(ctx context.Context, docID string) error

CompactView calls db.CompactViewFunc

func (*DB) CreateDoc

func (db *DB) CreateDoc(ctx context.Context, doc interface{}, opts map[string]interface{}) (string, string, error)

CreateDoc calls db.CreateDocFunc

func (*DB) Delete

func (db *DB) Delete(ctx context.Context, docID, rev string, opts map[string]interface{}) (string, error)

Delete calls db.DeleteFunc

func (*DB) DeleteAttachment

func (db *DB) DeleteAttachment(ctx context.Context, docID, rev, filename string, opts map[string]interface{}) (string, error)

DeleteAttachment calls db.DeleteAttachmentFunc

func (*DB) Get

func (db *DB) Get(ctx context.Context, docID string, opts map[string]interface{}) (*driver.Document, error)

Get calls db.GetFunc

func (*DB) GetAttachment

func (db *DB) GetAttachment(ctx context.Context, docID, filename string, opts map[string]interface{}) (*driver.Attachment, error)

GetAttachment calls db.GetAttachmentFunc

func (*DB) Put

func (db *DB) Put(ctx context.Context, docID string, doc interface{}, opts map[string]interface{}) (string, error)

Put calls db.PutFunc

func (*DB) PutAttachment

func (db *DB) PutAttachment(ctx context.Context, docID, rev string, att *driver.Attachment, opts map[string]interface{}) (string, error)

PutAttachment calls db.PutAttachmentFunc

func (*DB) Query

func (db *DB) Query(ctx context.Context, ddoc, view string, opts map[string]interface{}) (driver.Rows, error)

Query calls db.QueryFunc

func (*DB) Security

func (db *DB) Security(ctx context.Context) (*driver.Security, error)

Security calls db.SecurityFunc

func (*DB) SetSecurity

func (db *DB) SetSecurity(ctx context.Context, security *driver.Security) error

SetSecurity calls db.SetSecurityFunc

func (*DB) Stats

func (db *DB) Stats(ctx context.Context) (*driver.DBStats, error)

Stats calls db.StatsFunc

func (*DB) ViewCleanup

func (db *DB) ViewCleanup(ctx context.Context) error

ViewCleanup calls db.ViewCleanupFunc

type DBCloser

type DBCloser struct {
	*DB
	CloseFunc func(context.Context) error
}

DBCloser mocks driver.DB and driver.DBCloser

func (*DBCloser) Close

func (db *DBCloser) Close(ctx context.Context) error

Close calls db.CloseFunc

type DBUpdater

type DBUpdater struct {
	*Client
	DBUpdatesFunc func(context.Context) (driver.DBUpdates, error)
}

DBUpdater mocks driver.Client and driver.DBUpdater

func (*DBUpdater) DBUpdates

func (c *DBUpdater) DBUpdates(ctx context.Context) (driver.DBUpdates, error)

DBUpdates calls c.DBUpdatesFunc

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

func (*DBUpdates) Close

func (u *DBUpdates) Close() error

Close calls u.CloseFunc

func (*DBUpdates) Next

func (u *DBUpdates) Next(dbupdate *driver.DBUpdate) error

Next calls u.NextFunc

type DBsStatser

type DBsStatser struct {
	*Client
	DBsStatsFunc func(context.Context, []string) ([]*driver.DBStats, error)
}

DBsStatser mocks driver.Client and driver.DBsStatser

func (*DBsStatser) DBsStats

func (c *DBsStatser) DBsStats(ctx context.Context, dbnames []string) ([]*driver.DBStats, error)

DBsStats calls c.DBsStatsFunc

type DesignDocer

type DesignDocer struct {
	*DB
	DesignDocsFunc func(context.Context, map[string]interface{}) (driver.Rows, error)
}

DesignDocer mocks a driver.DB and driver.DesignDocer

func (*DesignDocer) DesignDocs

func (db *DesignDocer) DesignDocs(ctx context.Context, options map[string]interface{}) (driver.Rows, error)

DesignDocs calls db.DesignDocsFunc

type Driver

type Driver struct {
	NewClientFunc func(name string) (driver.Client, error)
}

Driver mocks a Kivik Driver.

func (*Driver) NewClient

func (d *Driver) NewClient(name string) (driver.Client, error)

NewClient calls d.NewClientFunc

type Finder

type Finder struct {
	*DB
	CreateIndexFunc func(context.Context, string, string, interface{}) error
	DeleteIndexFunc func(context.Context, string, string) error
	FindFunc        func(context.Context, interface{}) (driver.Rows, error)
	GetIndexesFunc  func(context.Context) ([]driver.Index, error)
	ExplainFunc     func(context.Context, interface{}) (*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{}) error

CreateIndex calls db.CreateIndexFunc

func (*Finder) DeleteIndex

func (db *Finder) DeleteIndex(ctx context.Context, ddoc, name string) error

DeleteIndex calls db.DeleteIndexFunc

func (*Finder) Explain

func (db *Finder) Explain(ctx context.Context, query interface{}) (*driver.QueryPlan, error)

Explain calls db.ExplainFunc

func (*Finder) Find

func (db *Finder) Find(ctx context.Context, query interface{}) (driver.Rows, error)

Find calls db.FindFunc

func (*Finder) GetIndexes

func (db *Finder) GetIndexes(ctx context.Context) ([]driver.Index, error)

GetIndexes calls db.GetIndexesFunc

type Flusher

type Flusher struct {
	*DB
	FlushFunc func(context.Context) error
}

Flusher mocks a driver.DB and driver.Flusher

func (*Flusher) Flush

func (db *Flusher) Flush(ctx context.Context) error

Flush calls db.FlushFunc

type LocalDocer

type LocalDocer struct {
	*DB
	LocalDocsFunc func(context.Context, map[string]interface{}) (driver.Rows, error)
}

LocalDocer mocks a driver.DB and driver.DesignDocer

func (*LocalDocer) LocalDocs

func (db *LocalDocer) LocalDocs(ctx context.Context, options map[string]interface{}) (driver.Rows, error)

LocalDocs calls db.LocalDocsFunc

type MetaGetter

type MetaGetter struct {
	*DB
	GetMetaFunc func(context.Context, string, map[string]interface{}) (int64, string, error)
}

MetaGetter mocks a driver.DB and driver.MetaGetter

func (*MetaGetter) GetMeta

func (db *MetaGetter) GetMeta(ctx context.Context, docID string, opts map[string]interface{}) (int64, string, error)

GetMeta calls db.GetMetaFunc

type OptsFinder

type OptsFinder struct {
	*DB
	CreateIndexFunc func(context.Context, string, string, interface{}, map[string]interface{}) error
	DeleteIndexFunc func(context.Context, string, string, map[string]interface{}) error
	FindFunc        func(context.Context, interface{}, map[string]interface{}) (driver.Rows, error)
	GetIndexesFunc  func(context.Context, map[string]interface{}) ([]driver.Index, error)
	ExplainFunc     func(context.Context, interface{}, map[string]interface{}) (*driver.QueryPlan, error)
}

OptsFinder mocks a driver.DB and driver.Finder

func (*OptsFinder) CreateIndex

func (db *OptsFinder) CreateIndex(ctx context.Context, ddoc, name string, index interface{}, opts map[string]interface{}) error

CreateIndex calls db.CreateIndexFunc

func (*OptsFinder) DeleteIndex

func (db *OptsFinder) DeleteIndex(ctx context.Context, ddoc, name string, opts map[string]interface{}) error

DeleteIndex calls db.DeleteIndexFunc

func (*OptsFinder) Explain

func (db *OptsFinder) Explain(ctx context.Context, query interface{}, opts map[string]interface{}) (*driver.QueryPlan, error)

Explain calls db.ExplainFunc

func (*OptsFinder) Find

func (db *OptsFinder) Find(ctx context.Context, query interface{}, opts map[string]interface{}) (driver.Rows, error)

Find calls db.FindFunc

func (*OptsFinder) GetIndexes

func (db *OptsFinder) GetIndexes(ctx context.Context, opts map[string]interface{}) ([]driver.Index, error)

GetIndexes calls db.GetIndexesFunc

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 Pinger

type Pinger struct {
	*Client
	PingFunc func(context.Context) (bool, error)
}

Pinger mocks driver.Client and driver.Pinger

func (*Pinger) Ping

func (c *Pinger) Ping(ctx context.Context) (bool, error)

Ping calls c.PingFunc

type Purger

type Purger struct {
	*DB
	PurgeFunc func(context.Context, map[string][]string) (*driver.PurgeResult, error)
}

Purger mocks a driver.DB and driver.Purger

func (*Purger) Purge

func (db *Purger) Purge(ctx context.Context, docMap map[string][]string) (*driver.PurgeResult, error)

Purge calls db.PurgeFunc

type QueryIndexer

type QueryIndexer struct {
	*Rows
	QueryIndexFunc func() int
}

QueryIndexer provides driver.QueryIndexer.

func (*QueryIndexer) QueryIndex

func (r *QueryIndexer) QueryIndex() int

QueryIndex calls r.QueryIndexFunc

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) EndTime

func (r *Replication) EndTime() time.Time

EndTime calls r.EndTimeFunc

func (*Replication) Err

func (r *Replication) Err() error

Err calls r.ErrFunc

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) State

func (r *Replication) State() string

State calls r.StateFunc

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 RevsDiffer

type RevsDiffer struct {
	*BulkDocer
	RevsDiffFunc func(context.Context, interface{}) (driver.Rows, error)
}

RevsDiffer mocks a driver.DB and driver.RevsDiffer.

func (*RevsDiffer) RevsDiff

func (db *RevsDiffer) RevsDiff(ctx context.Context, revMap interface{}) (driver.Rows, error)

RevsDiff calls db.RevsDiffFunc

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

func (*Rows) Close

func (r *Rows) Close() error

Close calls r.CloseFunc

func (*Rows) Next

func (r *Rows) Next(row *driver.Row) error

Next calls r.NextFunc

func (*Rows) Offset

func (r *Rows) Offset() int64

Offset calls r.OffsetFunc

func (*Rows) TotalRows

func (r *Rows) TotalRows() int64

TotalRows calls r.TotalRowsFunc

func (*Rows) UpdateSeq

func (r *Rows) UpdateSeq() string

UpdateSeq calls r.UpdateSeqFunc

type RowsWarner

type RowsWarner struct {
	*Rows
	WarningFunc func() string
}

RowsWarner wraps driver.RowsWarner

func (*RowsWarner) Warning

func (r *RowsWarner) Warning() string

Warning calls r.WarningFunc

type Sessioner

type Sessioner struct {
	*Client
	SessionFunc func(context.Context) (*driver.Session, error)
}

Sessioner mocks driver.Client and driver.Sessioner

func (*Sessioner) Session

func (s *Sessioner) Session(ctx context.Context) (*driver.Session, error)

Session calls s.SessionFunc