Documentation
¶
Overview ¶
Package fake provides an httptest-backed stand-in for a glutton actor.
Index ¶
- Constants
- type Server
- func (s *Server) HexDigest() string
- func (s *Server) RecordedPaths() []string
- func (s *Server) RecordedRAMReadSizes() []string
- func (s *Server) RecordedRAMWriteModes() []gluttonpb.WriteMode
- func (s *Server) RecordedRAMWriteSizes() []string
- func (s *Server) RecordedReadModes() []gluttonpb.ReadMode
- func (s *Server) RecordedWriteSizes() []int32
- func (s *Server) Start(t *testing.T) *httptest.Server
Constants ¶
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) RecordedPaths ¶
func (*Server) RecordedRAMReadSizes ¶
RecordedRAMReadSizes returns each /readram request's size string.
func (*Server) RecordedRAMWriteModes ¶
RecordedRAMWriteModes returns each /writeram request's write mode.
func (*Server) RecordedRAMWriteSizes ¶
RecordedRAMWriteSizes returns each /writeram request's size string.