Documentation
¶
Overview ¶
Package apptest provides in-memory doubles shared by tests that need an app.IdentityStore.
Index ¶
- func Control(ctx context.Context, store storage.Store, repoDir string, ids KeyStore) error
- func IsolateDataDir(m *testing.M) int
- func JoinRequest(ctx context.Context, store storage.Store, workspaceID string, ids KeyStore) (string, error)
- type KeyStore
- type Signers
- func (s *Signers) CreateSigner(workspaceID string) (signing.Signer, identity.SignerInfo, string, error)
- func (s *Signers) LoadSigner(workspaceID string) (signing.Signer, error)
- func (s *Signers) SignerInfo(workspaceID string) (identity.SignerInfo, error)
- func (s *Signers) Use(workspaceID string, key ed25519.PrivateKey)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Control ¶
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 ¶
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.
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 (*Signers) LoadSigner ¶
func (*Signers) SignerInfo ¶
func (s *Signers) SignerInfo(workspaceID string) (identity.SignerInfo, error)