apptest

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 13 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 apptest provides in-memory doubles shared by tests that need an app.IdentityStore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Control

func Control(ctx context.Context, store storage.Store, repoDir string, ids KeyStore) error

Control makes this device the founder of the workspace configured in repoDir: it writes the genesis Control and records its digest as control_genesis. It does nothing when the repository already has a genesis, so it is safe to call on a workspace that was initialized through the real flow.

func IsolateDataDir

func IsolateDataDir(m *testing.M) int

IsolateDataDir runs the tests with XDG_DATA_HOME pointing at a throwaway directory, so checkpoints and local state never touch the real per-user data directory, and returns the exit code. Use it as:

func TestMain(m *testing.M) { os.Exit(apptest.IsolateDataDir(m)) }

pkg/config reads XDG_DATA_HOME first on every platform.

func JoinRequest

func JoinRequest(ctx context.Context, store storage.Store, workspaceID string, ids KeyStore) (string, error)

JoinRequest makes this device ask to join the workspace, as `enbu init` does for a device that is not a member. It returns the device id.

Types

type KeyStore

type KeyStore interface {
	Create(workspaceID string) (identity.Identity, identity.PublicInfo, string, error)
	CreateSigner(workspaceID string) (signing.Signer, identity.SignerInfo, string, error)
}

KeyStore is the part of an identity store these helpers need. It matches app.IdentityStore without importing app, which would be a cycle for app's own tests.

type Signers

type Signers struct {
	// contains filtered or unexported fields
}

Signers keeps one Ed25519 signing key per workspace in memory. Embed it in an identity store double; the zero value is ready to use.

func (*Signers) CreateSigner

func (s *Signers) CreateSigner(workspaceID string) (signing.Signer, identity.SignerInfo, string, error)

func (*Signers) LoadSigner

func (s *Signers) LoadSigner(workspaceID string) (signing.Signer, error)

func (*Signers) SignerInfo

func (s *Signers) SignerInfo(workspaceID string) (identity.SignerInfo, error)

func (*Signers) Use

func (s *Signers) Use(workspaceID string, key ed25519.PrivateKey)

Use installs a signer as the workspace's signing key, for tests that need to know a device's identity up front.

Jump to

Keyboard shortcuts

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