Help us shape the future of Go! Take the 2026 Go Developer Survey

sharedtest

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package sharedtest is a small in-process stand-in for a Valkey or Redis server, for tests of code that talks to one. It speaks just enough RESP: AUTH, PING, SET (NX, PX), GET and DEL, with expiry on a clock the test moves by hand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// Addr is host:port to connect to.
	Addr string
	// contains filtered or unexported fields
}

Server is a fake Valkey listening on loopback.

func Start

func Start(t testing.TB, password string) *Server

Start launches a server that asks for password when it is not empty. It stops when the test ends.

func (*Server) Advance

func (s *Server) Advance(d time.Duration)

Advance moves the server's clock, expiring keys.

func (*Server) Close

func (s *Server) Close()

Close stops listening and drops every connection.

func (*Server) Commands

func (s *Server) Commands() []string

Commands lists the command names received, in order.

func (*Server) Connections

func (s *Server) Connections() int

Connections is how many client connections have been accepted so far.

func (*Server) DropConnections

func (s *Server) DropConnections()

DropConnections closes every client connection but keeps listening, as a restart of a proxy or an idle timeout would.

func (*Server) Get

func (s *Server) Get(key string) (string, bool)

Get returns a key's value as the server holds it.

func (*Server) Keys

func (s *Server) Keys() []string

Keys lists the live keys.

Jump to

Keyboard shortcuts

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