kivik: github.com/go-kivik/kivik/internal/mock Index | Files

package mock

import "github.com/go-kivik/kivik/internal/mock"

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

Index

Package Files

attachments.go bulkdocer.go bulkresults.go changes.go client.go db.go dbupdates.go doc.go driver.go replication.go rows.go sessioner.go

type AttachmentMetaGetter Uses

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 Uses

func (db *AttachmentMetaGetter) GetAttachmentMeta(ctx context.Context, docID, filename string, options map[string]interface{}) (*driver.Attachment, error)

GetAttachmentMeta calls db.GetAttachmentMetaFunc

type Attachments Uses

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 Uses

func (a *Attachments) Close() error

Close calls a.CloseFunc

func (*Attachments) Next Uses

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

Next calls a.NextFunc

type Authenticator Uses

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

Authenticator mocks driver.Client and driver.Authenticator

func (*Authenticator) Authenticate Uses

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

Authenticate calls c.AuthenticateFunc

type Bookmarker Uses

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

Bookmarker wraps driver.Bookmarker

func (*Bookmarker) Bookmark Uses

func (r *Bookmarker) Bookmark() string

Bookmark calls r.BookmarkFunc

type BulkDocer Uses

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 Uses

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

BulkDocs calls db.BulkDocsFunc

type BulkGetter Uses

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 Uses

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

BulkGet calls db.BulkGetFunc

type BulkResults Uses

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 Uses

func (r *BulkResults) Close() error

Close calls r.CloseFunc

func (*BulkResults) Next Uses

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

Next calls r.NextFunc

type Changes Uses

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 Uses

func (c *Changes) Close() error

Close calls c.CloseFunc

func (*Changes) ETag Uses

func (c *Changes) ETag() string

ETag calls c.ETagFunc

func (*Changes) LastSeq Uses

func (c *Changes) LastSeq() string

LastSeq calls c.LastSeqFunc

func (*Changes) Next Uses

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

Next calls c.NextFunc

func (*Changes) Pending Uses

func (c *Changes) Pending() int64

Pending calls c.PendingFunc

type Client Uses

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 Uses

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

AllDBs calls c.AllDBsFunc

func (*Client) CreateDB Uses

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

CreateDB calls c.CreateDBFunc

func (*Client) DB Uses

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

DB calls c.DBFunc

func (*Client) DBExists Uses

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

DBExists calls c.DBExistsFunc

func (*Client) DestroyDB Uses

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

DestroyDB calls c.DestroyDBFunc

func (*Client) Version Uses

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

Version calls c.VersionFunc

type ClientCloser Uses

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

ClientCloser mocks driver.Client and driver.ClientCloser

func (*ClientCloser) Close Uses

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

Close calls c.CloseFunc

type ClientReplicator Uses

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 Uses

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

GetReplications calls c.GetReplicationsFunc

func (*ClientReplicator) Replicate Uses

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

Replicate calls c.ReplicateFunc

type Cluster Uses

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 Uses

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

ClusterSetup calls c.ClusterSetupFunc

func (*Cluster) ClusterStatus Uses

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

ClusterStatus calls c.ClusterStatusFunc

type Configer Uses

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 Uses

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

Config calls c.ConfigFunc

func (*Configer) ConfigSection Uses

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

ConfigSection calls c.ConfSectionFunc

func (*Configer) ConfigValue Uses

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

ConfigValue calls c.ConfigValueFunc

func (*Configer) DeleteConfigKey Uses

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

DeleteConfigKey calls c.DeleteConfigKeyFunc

func (*Configer) SetConfigValue Uses

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

SetConfigValue calls c.SetConfigValueFunc

type Copier Uses

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 Uses

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

Copy calls db.CopyFunc

type DB Uses

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 Uses

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

AllDocs calls db.AllDocsFunc

func (*DB) Changes Uses

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

Changes calls db.ChangesFunc

func (*DB) Compact Uses

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

Compact calls db.CompactFunc

func (*DB) CompactView Uses

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

CompactView calls db.CompactViewFunc

func (*DB) CreateDoc Uses

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

CreateDoc calls db.CreateDocFunc

func (*DB) Delete Uses

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

Delete calls db.DeleteFunc

func (*DB) DeleteAttachment Uses

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

DeleteAttachment calls db.DeleteAttachmentFunc

func (*DB) Get Uses

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

Get calls db.GetFunc

func (*DB) GetAttachment Uses

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

GetAttachment calls db.GetAttachmentFunc

func (*DB) Put Uses

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

Put calls db.PutFunc

func (*DB) PutAttachment Uses

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 Uses

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

Query calls db.QueryFunc

func (*DB) Security Uses

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

Security calls db.SecurityFunc

func (*DB) SetSecurity Uses

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

SetSecurity calls db.SetSecurityFunc

func (*DB) Stats Uses

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

Stats calls db.StatsFunc

func (*DB) ViewCleanup Uses

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

ViewCleanup calls db.ViewCleanupFunc

type DBCloser Uses

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

DBCloser mocks driver.DB and driver.DBCloser

func (*DBCloser) Close Uses

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

Close calls db.CloseFunc

type DBUpdater Uses

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

DBUpdater mocks driver.Client and driver.DBUpdater

func (*DBUpdater) DBUpdates Uses

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

DBUpdates calls c.DBUpdatesFunc

type DBUpdates Uses

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 Uses

func (u *DBUpdates) Close() error

Close calls u.CloseFunc

func (*DBUpdates) Next Uses

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

Next calls u.NextFunc

type DBsStatser Uses

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

DBsStatser mocks driver.Client and driver.DBsStatser

func (*DBsStatser) DBsStats Uses

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

DBsStats calls c.DBsStatsFunc

type DesignDocer Uses

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 Uses

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

DesignDocs calls db.DesignDocsFunc

type Driver Uses

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

Driver mocks a Kivik Driver.

func (*Driver) NewClient Uses

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

NewClient calls d.NewClientFunc

type Finder Uses

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 Uses

func (db *Finder) CreateIndex(ctx context.Context, ddoc, name string, index interface{}) error

CreateIndex calls db.CreateIndexFunc

func (*Finder) DeleteIndex Uses

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

DeleteIndex calls db.DeleteIndexFunc

func (*Finder) Explain Uses

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

Explain calls db.ExplainFunc

func (*Finder) Find Uses

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

Find calls db.FindFunc

func (*Finder) GetIndexes Uses

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

GetIndexes calls db.GetIndexesFunc

type Flusher Uses

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

Flusher mocks a driver.DB and driver.Flusher

func (*Flusher) Flush Uses

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

Flush calls db.FlushFunc

type LocalDocer Uses

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 Uses

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

LocalDocs calls db.LocalDocsFunc

type MetaGetter Uses

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 Uses

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

GetMeta calls db.GetMetaFunc

type Pinger Uses

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

Pinger mocks driver.Client and driver.Pinger

func (*Pinger) Ping Uses

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

Ping calls c.PingFunc

type Purger Uses

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 Uses

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

Purge calls db.PurgeFunc

type Replication Uses

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 Uses

func (r *Replication) Delete(ctx context.Context) error

Delete calls r.DeleteFunc

func (*Replication) EndTime Uses

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

EndTime calls r.EndTimeFunc

func (*Replication) Err Uses

func (r *Replication) Err() error

Err calls r.ErrFunc

func (*Replication) ReplicationID Uses

func (r *Replication) ReplicationID() string

ReplicationID calls r.ReplicatoinIDFunc

func (*Replication) Source Uses

func (r *Replication) Source() string

Source calls r.SourceFunc or returns a default value if SourceFunc is nil

func (*Replication) StartTime Uses

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

StartTime calls r.StartTimeFunc

func (*Replication) State Uses

func (r *Replication) State() string

State calls r.StateFunc

func (*Replication) Target Uses

func (r *Replication) Target() string

Target calls r.TargetFunc or returns a default if TargetFunc is nil

func (*Replication) Update Uses

func (r *Replication) Update(ctx context.Context, rep *driver.ReplicationInfo) error

Update calls r.UpdateFunc

type RevsDiffer Uses

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

RevsDiffer mocks a driver.DB and driver.RevsDiffer.

func (*RevsDiffer) RevsDiff Uses

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

RevsDiff calls db.RevsDiffFunc

type Rows Uses

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 Uses

func (r *Rows) Close() error

Close calls r.CloseFunc

func (*Rows) Next Uses

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

Next calls r.NextFunc

func (*Rows) Offset Uses

func (r *Rows) Offset() int64

Offset calls r.OffsetFunc

func (*Rows) TotalRows Uses

func (r *Rows) TotalRows() int64

TotalRows calls r.TotalRowsFunc

func (*Rows) UpdateSeq Uses

func (r *Rows) UpdateSeq() string

UpdateSeq calls r.UpdateSeqFunc

type RowsWarner Uses

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

RowsWarner wraps driver.RowsWarner

func (*RowsWarner) Warning Uses

func (r *RowsWarner) Warning() string

Warning calls r.WarningFunc

type Sessioner Uses

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

Sessioner mocks driver.Client and driver.Sessioner

func (*Sessioner) Session Uses

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

Session calls s.SessionFunc

Package mock imports 3 packages (graph). Updated 2019-09-21. Refresh now. Tools for package owners.