fake

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Overview

Package fake is a backend of the dev UI in memory, for the tests of its pages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Data Data
	// contains filtered or unexported fields
}

Backend is a deps.Backend that answers from Data and records every call but those of Personas and Changed. A method fails with the error Data.Errors holds for it, and with E-DEV-014 for an app Data.Status does not list. Set Data before the Backend is shared and change it only through Update after. A Backend is safe for concurrent use.

func (*Backend) Calls

func (b *Backend) Calls(methods ...string) []Call

Calls returns the calls to the methods named, or every call when none is named, in order.

func (*Backend) Change

func (b *Backend) Change()

Change closes the channel Changed returned, as the workspace does at every change.

func (*Backend) Changed

func (b *Backend) Changed() <-chan struct{}

Changed returns a channel that Change closes.

func (*Backend) Logs

Logs returns Data.Logs.

func (*Backend) Mail

func (b *Backend) Mail(_ context.Context, app string) ([]devapi.MailSummary, error)

Mail returns the summaries of the messages of app.

func (*Backend) MailGet

func (b *Backend) MailGet(_ context.Context, app, id string) (devapi.Mail, error)

MailGet returns the message id of app.

func (*Backend) MailReceive

func (b *Backend) MailReceive(_ context.Context, app string, m devapi.InboundMail) (string, error)

MailReceive adds m to the end of the messages of app, in the folder "inbox", and calls Change.

func (*Backend) Personas

func (b *Backend) Personas() []devconfig.Persona

Personas returns Data.Personas.

func (*Backend) Restart

func (b *Backend) Restart(_ context.Context, app string) (devapi.App, error)

Restart returns the status of app.

func (*Backend) SetManual

func (b *Backend) SetManual(app string, on bool) error

SetManual records the call.

func (*Backend) Start

func (b *Backend) Start(app string) error

Start records the call.

func (*Backend) Status

func (b *Backend) Status(context.Context) (devapi.Status, error)

Status returns Data.Status.

func (*Backend) Stop

func (b *Backend) Stop(app string) error

Stop records the call.

func (*Backend) Trace

func (b *Backend) Trace(_ context.Context, id string) (devapi.Trace, error)

Trace returns the spans of Data.Spans whose trace id is id.

func (*Backend) Traces

Traces returns Data.Traces.

func (*Backend) Update

func (b *Backend) Update(f func(*Data))

Update changes the data while it holds the Backend's lock, then calls Change.

func (*Backend) WhatBroke

func (b *Backend) WhatBroke(_ context.Context, app string) (devapi.Broken, error)

WhatBroke returns Data.Broken.

type Call

type Call struct {
	Method string
	App    string
	// Arg is the call's other argument: the query of Logs and Traces, the id of Trace and
	// MailGet, the message of MailReceive and the switch of SetManual.
	Arg any
}

Call is one call a Backend got.

type Data

type Data struct {
	Status devapi.Status
	// Logs answers every query of Logs, and Traces every query of Traces; Calls holds the
	// queries.
	Logs   []devapi.LogEntry
	Traces []devapi.TraceSummary
	// Spans holds the spans Trace finds by trace id.
	Spans []devapi.Span
	// Mail holds the messages of each app, in the order Mail lists them.
	Mail     map[string][]devapi.Mail
	Broken   devapi.Broken
	Personas []devconfig.Persona
	// Errors holds the error each method, by name, fails with.
	Errors map[string]error
}

Data is what a Backend answers.

Jump to

Keyboard shortcuts

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