etcdtest

package
v0.34.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package etcdtest provides in-memory fakes of etcd client interfaces for unit tests.

Index

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 NewFakeKV

func NewFakeKV(kvs map[string]string) *FakeKV

NewFakeKV returns a FakeKV serving the given key/value pairs.

func (*FakeKV) Delete

func (*FakeKV) Do

func (*FakeKV) Get

func (f *FakeKV) Get(_ context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)

func (*FakeKV) GetStream

func (*FakeKV) Put

func (*FakeKV) Txn

func (f *FakeKV) Txn(context.Context) clientv3.Txn

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL