fake

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package fake provides an httptest-backed stand-in for a glutton actor.

Index

Constants

View Source
const (
	WriteDiskRoute = "/writedisk"
	ReadDiskRoute  = "/readdisk"
	WriteRAMRoute  = "/writeram"
	ReadRAMRoute   = "/readram"
)

Routes the fake serves, mirroring glutton's real HTTP mux. Declared here so the fake depends on nothing; collapses onto one source when glutton's core moves.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// Data is the file the actor holds, driving size, digest, and payload.
	Data []byte
	// Digest overrides the sha256 returned by both routes, leaving size and payload honest.
	Digest []byte
	// CorruptPayload is served by /readdisk instead of Data, keeping size and digest honest.
	CorruptPayload []byte
	// EmptyPayload causes /readdisk to omit the Data field entirely (digest-only wire format).
	// Silently takes precedence over CorruptPayload if both are set.
	EmptyPayload bool
	// Status fails every route with this HTTP status code.
	Status int
	// ElapsedUs sets the x-server-elapsed-us timing header/trailer.
	ElapsedUs string
	// contains filtered or unexported fields
}

Server is an httptest-backed stand-in for a glutton actor holding one file. The Data slice is the source of truth: both routes report len(Data) and sha256(Data), and /readdisk serves Data as payload. Each override field makes the actor lie about exactly one property.

func (*Server) HexDigest

func (s *Server) HexDigest() string

func (*Server) RecordedPaths

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

func (*Server) RecordedRAMReadSizes

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

RecordedRAMReadSizes returns each /readram request's size string.

func (*Server) RecordedRAMWriteModes

func (s *Server) RecordedRAMWriteModes() []gluttonpb.WriteMode

RecordedRAMWriteModes returns each /writeram request's write mode.

func (*Server) RecordedRAMWriteSizes

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

RecordedRAMWriteSizes returns each /writeram request's size string.

func (*Server) RecordedReadModes

func (s *Server) RecordedReadModes() []gluttonpb.ReadMode

func (*Server) RecordedWriteSizes

func (s *Server) RecordedWriteSizes() []int32

func (*Server) Start

func (s *Server) Start(t *testing.T) *httptest.Server

Jump to

Keyboard shortcuts

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