fake

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 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 fake provides an httptest-backed stand-in for a glutton actor.

Index

Constants

View Source
const (
	WriteDiskRoute = glutton.WriteDiskRoute
	ReadDiskRoute  = glutton.ReadDiskRoute
	WriteRAMRoute  = glutton.WriteRAMRoute
	ReadRAMRoute   = glutton.ReadRAMRoute
	BurnCPURoute   = glutton.BurnCPURoute
	IngestRoute    = glutton.IngestRoute
	PingRoute      = glutton.PingRoute
	UseCPURoute    = glutton.UseCPURoute
	RunScriptRoute = glutton.RunScriptRoute
)

Routes the fake serves, re-exported from the real server so the stand-in cannot answer a path the actor does not.

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) RecordedBurnMillis

func (s *Server) RecordedBurnMillis() []int64

RecordedBurnMillis returns each /burncpu request's duration_ms.

func (*Server) RecordedCPURequests

func (s *Server) RecordedCPURequests() []*gluttonpb.UseCPURequest

RecordedCPURequests returns each /usecpu request.

func (*Server) RecordedIngestSizes

func (s *Server) RecordedIngestSizes() []int64

RecordedIngestSizes returns each /ingest request's payload length.

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) RecordedScripts

func (s *Server) RecordedScripts() []*gluttonpb.RunScriptRequest

RecordedScripts returns each /runscript request.

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