Documentation
¶
Overview ¶
Package etcdtest provides in-memory fakes of etcd client interfaces for unit tests.
Index ¶
- type FakeKV
- func (f *FakeKV) Compact(context.Context, int64, ...clientv3.CompactOption) (*clientv3.CompactResponse, error)
- func (f *FakeKV) Delete(context.Context, string, ...clientv3.OpOption) (*clientv3.DeleteResponse, error)
- func (f *FakeKV) Do(context.Context, clientv3.Op) (clientv3.OpResponse, error)
- func (f *FakeKV) Get(_ context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
- func (f *FakeKV) GetStream(context.Context, string, ...clientv3.OpOption) (clientv3.GetStreamChan, error)
- func (f *FakeKV) Put(context.Context, string, string, ...clientv3.OpOption) (*clientv3.PutResponse, error)
- func (f *FakeKV) Txn(context.Context) clientv3.Txn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeKV ¶
type FakeKV struct {
// KVs holds the key/value pairs served by Get.
KVs map[string]string
// Leases optionally maps keys to the lease ID reported on them.
Leases map[string]int64
// Requests records every Get op issued, in order.
Requests []clientv3.Op
// ValueKeys records every key whose value was returned, i.e. that was
// served by a Get without WithKeysOnly.
ValueKeys []string
// ReturnedKeys counts the keys returned across all Gets.
ReturnedKeys int
}
FakeKV is a minimal in-memory fake of clientv3.KV for unit-testing range scans. It supports only Get, with an optional range end, limit and keys-only flag. All other methods panic.
Every Get is recorded so tests can assert on how a scanner walked the keyspace.
func (*FakeKV) Compact ¶
func (f *FakeKV) Compact(context.Context, int64, ...clientv3.CompactOption) (*clientv3.CompactResponse, error)