stacktest

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 6 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 stacktest provides an in-memory stack backend for tests. Branch creation and checkout happen in the real temporary repository; the graph lives in memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RestoreGraph added in v0.4.0

func RestoreGraph(s stack.Snapshot) (*stack.Graph, error)

RestoreGraph is an in-memory backend's Restore: the graph SnapshotGraph copied.

func SnapshotGraph added in v0.4.0

func SnapshotGraph(g *stack.Graph) (stack.Snapshot, error)

SnapshotGraph is an in-memory backend's Snapshot: a deep copy of g, as JSON, under a single key.

Types

type Backend

type Backend struct {

	// Submits records submit options; SubmitFn, when set, runs on submit.
	Submits  []stack.SubmitOptions
	SubmitFn func(o stack.SubmitOptions) error
	// Links records link options.
	Links []stack.LinkOptions

	// Unstacked records every Unstack call; UnstackFn, when set, decides
	// its result.
	Unstacked []int
	UnstackFn func(number int) error
	// contains filtered or unexported fields
}

Backend implements every stack port in memory.

func New

func New(g *git.Client, graph *stack.Graph) *Backend

New returns a Backend over g with the given initial graph.

func (*Backend) AddTop

func (b *Backend) AddTop(ctx context.Context, repo git.Repo, name string) error

func (*Backend) Graph

func (b *Backend) Graph() *stack.Graph

Graph returns the current graph.

func (*Backend) InitStack

func (b *Backend) InitStack(ctx context.Context, repo git.Repo, trunk string, branches []string) error

func (*Backend) Load

func (b *Backend) Load(context.Context, git.Repo) (*stack.Graph, error)

func (*Backend) Restore added in v0.4.0

func (b *Backend) Restore(_ context.Context, _ git.Repo, s stack.Snapshot) error

func (*Backend) SetGraph

func (b *Backend) SetGraph(g *stack.Graph)

SetGraph replaces the graph.

func (*Backend) Snapshot added in v0.4.0

func (b *Backend) Snapshot(context.Context, git.Repo) (stack.Snapshot, error)

func (*Backend) Submit

func (*Backend) Unstack added in v0.3.0

func (b *Backend) Unstack(_ context.Context, _ git.Repo, number int) error

func (*Backend) Update added in v0.1.4

func (b *Backend) Update(_ context.Context, _ git.Repo, fn func(*stack.Graph) error) error

Jump to

Keyboard shortcuts

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