unit

package
v1.999.330 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package unit is the in-process single-process test harness. It spawns exactly one gen.ProcessBehavior (act.Actor, act.Supervisor and the rest are just sugar over it) with a mocked gen.Process. That mock process's Node() returns a mock gen.Node, and both delegate every outbound operation to that mock node, which records the egress as check.Records and lets the test stub what those operations return (including errors) to exercise negative paths. Assertions use the shared testing/check grammar, identical to testing/stage; the differences are the mock environment and synchronous (snapshot) assertions.

Plane contract: this harness records egress (what the actor does) and its own termination (Terminated), delayed sends (SendAfter), and logs (Log). It does NOT produce the ingress records (Delivered, Down, Exit, Event, and the Wire* subscriptions): inbound signals are driven by the test via the Deliver* methods, so there is nothing to observe on the way in. Assert an actor's reaction to a delivery, not the delivery itself. Those ingress records are testing/stage-only.

A send the actor addresses to itself is treated the same way: recorded as egress, not looped back into its own mailbox. To drive the reaction, re-deliver it with SendMessage. A Call the actor makes to itself is an outbound Call like any other and needs a stubbed response (OnCall); it does not re-enter the actor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallStub added in v1.999.330

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

CallStub stubs the process's outbound Call to a target.

func (*CallStub) Fail added in v1.999.330

func (s *CallStub) Fail(err error)

Fail returns (nil, err) for a matching call.

func (*CallStub) Respond added in v1.999.330

func (s *CallStub) Respond(resp any)

Respond returns (resp, nil) for a matching call.

func (*CallStub) RespondWith added in v1.999.330

func (s *CallStub) RespondWith(fn func(request any) (any, error))

RespondWith computes the (response, error) from the actual request.

func (*CallStub) Where added in v1.999.330

func (s *CallStub) Where(m check.Matcher) *CallStub

Where narrows the stub to requests matching m.

type CreateAliasStub added in v1.999.330

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

CreateAliasStub stubs CreateAlias.

func (*CreateAliasStub) Fail added in v1.999.330

func (s *CreateAliasStub) Fail(err error)

Fail makes CreateAlias return err.

func (*CreateAliasStub) Return added in v1.999.330

func (s *CreateAliasStub) Return(alias gen.Alias)

Return makes CreateAlias return alias.

type EventSubscribeStub added in v1.999.330

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

EventSubscribeStub stubs LinkEvent/MonitorEvent (matched by event): it sets the buffered events the subscription replays, or makes the subscription fail. A stub event with an empty Node matches the event of that name on any node.

func (*EventSubscribeStub) Fail added in v1.999.330

func (s *EventSubscribeStub) Fail(err error)

Fail makes the subscription return err.

func (*EventSubscribeStub) Return added in v1.999.330

func (s *EventSubscribeStub) Return(buffer []gen.MessageEvent)

Return makes the subscription return buffer, as a live producer replays its ring buffer to a new subscriber.

type FailStub added in v1.999.330

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

FailStub makes an error-only operation to a target fail.

func (*FailStub) Fail added in v1.999.330

func (s *FailStub) Fail(err error)

Fail sets the error returned for a matching operation.

func (*FailStub) FailFunc added in v1.999.330

func (s *FailStub) FailFunc(fn func() error)

FailFunc computes the error per matching invocation. A counter in the closure fails selectively, e.g. only the 2nd and 5th call:

i := 0
sub.OnSend("svc").FailFunc(func() error {
	i++
	if i == 2 || i == 5 { return gen.ErrProcessMailboxFull }
	return nil
})

type MetaSubject added in v1.999.330

type MetaSubject struct {
	*check.Asserter
	// contains filtered or unexported fields
}

MetaSubject drives a meta-process behavior under test. It is spawned from an actor Subject (sub.SpawnMeta), inheriting the parent PID and environment, and shares the parent's record stream: a meta's egress (Send, SendResponse, child SpawnMeta, Log) is observed as originating from the parent PID, exactly as the real runtime routes it. Scope an assertion to the meta phase with Since(mark) when the parent and the meta both send.

The drivers mirror the meta runtime: DeliverMessage runs HandleMessage, Request runs HandleCall (auto-responding with a non-nil result), Inspect runs HandleInspect, Terminate runs Terminate. The blocking Start() integration loop is out of scope for the unit harness (it belongs in the stage harness); the thin Start() driver is provided only for non-blocking Start() implementations.

func (*MetaSubject) Behavior added in v1.999.330

func (m *MetaSubject) Behavior() gen.MetaBehavior

Behavior returns the meta behavior under test for white-box assertions.

func (*MetaSubject) DeliverMessage added in v1.999.330

func (m *MetaSubject) DeliverMessage(from gen.PID, message any) *MetaSubject

DeliverMessage delivers an async message to the meta, running HandleMessage in the Running state. A non-nil return terminates the meta.

func (*MetaSubject) FireTimers added in v1.999.330

func (m *MetaSubject) FireTimers() int

FireTimers delivers the scheduled (and not cancelled) timers this meta addressed to its own alias into HandleMessage, in scheduling order, and returns how many fired. Timers addressed elsewhere belong to the parent Subject's FireTimers.

func (*MetaSubject) ID added in v1.999.330

func (m *MetaSubject) ID() gen.Alias

ID returns the alias identifying this meta process.

func (*MetaSubject) Inspect added in v1.999.330

func (m *MetaSubject) Inspect(from gen.PID, items ...string) map[string]string

Inspect runs HandleInspect in the Running state and returns its map.

func (*MetaSubject) OnSend added in v1.999.330

func (m *MetaSubject) OnSend(to any) *FailStub

func (*MetaSubject) OnSpawnMeta added in v1.999.330

func (m *MetaSubject) OnSpawnMeta(sample gen.MetaBehavior) *SpawnMetaStub

func (*MetaSubject) Parent added in v1.999.330

func (m *MetaSubject) Parent() gen.PID

Parent returns the PID of the parent actor that spawned this meta.

func (*MetaSubject) Request added in v1.999.330

func (m *MetaSubject) Request(from gen.PID, request any) (any, error)

Request delivers a synchronous request to the meta, running HandleCall in the Running state, and returns the result and error. A non-nil result with no error (or TerminateReasonNormal) is auto-recorded as a SendResponse, mirroring the runtime. A non-normal error terminates the meta.

func (*MetaSubject) Run added in v1.999.330

func (m *MetaSubject) Run() error

Run runs the prepared meta's Init. SpawnMeta calls this for you; after PrepareMeta call it explicitly. Calling Run twice fails loudly. If Init fails the meta is left terminated and the error is returned.

func (*MetaSubject) Start added in v1.999.330

func (m *MetaSubject) Start() error

Start runs the behavior's Start() synchronously and then terminates the meta with its result (TerminateReasonNormal if nil), mirroring the runtime where a returning Start() ends the meta. Only for non-blocking Start() implementations; a Start() that blocks on I/O belongs in the stage harness.

func (*MetaSubject) State added in v1.999.330

func (m *MetaSubject) State() gen.MetaState

State returns the current meta state (Sleep, Running, or Terminated).

func (*MetaSubject) Terminate added in v1.999.330

func (m *MetaSubject) Terminate(reason error) *MetaSubject

Terminate runs the behavior's Terminate(reason) and marks the meta terminated.

type MockNetwork added in v1.999.330

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

MockNetwork is the test-config handle for Node().Network(); it shadows the embedded gen.Network (which the actor still sees) and exposes configuration of the built-in mock network.

func (*MockNetwork) FailRegisterTypes added in v1.999.330

func (m *MockNetwork) FailRegisterTypes(err error)

FailRegisterTypes makes RegisterType / RegisterTypes return err.

func (*MockNetwork) FailRegistrar added in v1.999.330

func (m *MockNetwork) FailRegistrar(err error)

FailRegistrar makes Network().Registrar() return err (no registrar configured).

func (*MockNetwork) LookupType added in v1.999.330

func (m *MockNetwork) LookupType(name string) (reflect.Type, bool)

LookupType and RegisteredTypes read the mock registry, so a test can assert what the actor under test registered.

func (*MockNetwork) OnGetNode added in v1.999.330

func (m *MockNetwork) OnGetNode(name gen.Atom) *MockRemoteNode

OnGetNode returns the test-config handle for the remote node `name`. Until configured, Network().GetNode(name)/Node(name) return gen.ErrNoConnection.

func (*MockNetwork) RegisterTypes added in v1.999.330

func (m *MockNetwork) RegisterTypes(types []any) error

RegisterTypes seeds the mock registry the way an application's Load does, so an actor that checks its own wire surface faces the same precondition as in production.

func (*MockNetwork) RegisteredAtoms added in v1.999.330

func (m *MockNetwork) RegisteredAtoms() []gen.RegisteredAtomInfo

func (*MockNetwork) RegisteredErrors added in v1.999.330

func (m *MockNetwork) RegisteredErrors() []gen.RegisteredErrorInfo

RegisteredErrors and RegisteredAtoms report what the actor registered, so a test can assert that its cross-node sentinels and atoms are in the registry.

func (*MockNetwork) RegisteredTypes added in v1.999.330

func (m *MockNetwork) RegisteredTypes() []gen.RegisteredTypeInfo

func (*MockNetwork) Registrar added in v1.999.330

func (m *MockNetwork) Registrar() *MockRegistrar

Registrar returns the test-config handle for Network().Registrar().

type MockNode added in v1.999.330

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

MockNode is the test-facing mock node. It embeds the mocked gen.Node, so every node method (ProcessInfo, ProcessList, ...) and every On<Method> override setter is available directly on it; its own Spawn / SpawnRegister shadow gen.Node.Spawn to return the Subject under test (unit exercises exactly that one process). It is returned both by unit.StartNode(...) (configure before spawn) and by Subject.Node() (configure / inspect after spawn).

Node().Network() returns a built-in stubbable mock network (configure discovery via Node().Network().Registrar().Resolver().OnResolve / OnResolveApplication). Node().Cron() returns a built-in mock cron (add jobs via Node().Cron().AddJob; drive via Subject.FireCron).

func StartNode added in v1.999.330

func StartNode(t testing.TB, name gen.Atom, options gen.NodeOptions) *MockNode

Node creates a mock node. Mirrors stage's s.StartNode(name, NodeOptions): spawn the process under test on the returned node with Spawn / SpawnRegister. Env is taken from options.Env; the rest of gen.NodeOptions is accepted for parity with a real node but unused by the mock.

func (MockNode) ApplicationInfo added in v1.999.330

func (n MockNode) ApplicationInfo(name gen.Atom) (gen.ApplicationInfo, error)

func (MockNode) ApplicationLoad added in v1.999.330

func (n MockNode) ApplicationLoad(app gen.ApplicationBehavior, args ...any) (gen.Atom, error)

func (MockNode) ApplicationProcessList added in v1.999.330

func (n MockNode) ApplicationProcessList(name gen.Atom, limit int) ([]gen.PID, error)

func (MockNode) ApplicationProcessListShortInfo added in v1.999.330

func (n MockNode) ApplicationProcessListShortInfo(name gen.Atom, limit int) ([]gen.ProcessShortInfo, int, error)

func (MockNode) ApplicationStart added in v1.999.330

func (n MockNode) ApplicationStart(name gen.Atom, options gen.ApplicationOptions) error

func (MockNode) ApplicationStartPermanent added in v1.999.330

func (n MockNode) ApplicationStartPermanent(name gen.Atom, options gen.ApplicationOptions) error

func (MockNode) ApplicationStartTemporary added in v1.999.330

func (n MockNode) ApplicationStartTemporary(name gen.Atom, options gen.ApplicationOptions) error

func (MockNode) ApplicationStartTransient added in v1.999.330

func (n MockNode) ApplicationStartTransient(name gen.Atom, options gen.ApplicationOptions) error

func (MockNode) ApplicationStop added in v1.999.330

func (n MockNode) ApplicationStop(name gen.Atom) error

func (MockNode) ApplicationStopForce added in v1.999.330

func (n MockNode) ApplicationStopForce(name gen.Atom) error

func (MockNode) ApplicationStopWithTimeout added in v1.999.330

func (n MockNode) ApplicationStopWithTimeout(name gen.Atom, timeout time.Duration) error

func (MockNode) ApplicationUnload added in v1.999.330

func (n MockNode) ApplicationUnload(name gen.Atom) error

func (MockNode) Applications added in v1.999.330

func (n MockNode) Applications() []gen.Atom

func (MockNode) ApplicationsRunning added in v1.999.330

func (n MockNode) ApplicationsRunning() []gen.Atom

func (MockNode) Call added in v1.999.330

func (n MockNode) Call(to any, request any) (any, error)

func (MockNode) CallAlias added in v1.999.330

func (n MockNode) CallAlias(to gen.Alias, request any, timeout int) (any, error)

func (MockNode) CallImportant added in v1.999.330

func (n MockNode) CallImportant(to any, request any) (any, error)

func (MockNode) CallPID added in v1.999.330

func (n MockNode) CallPID(to gen.PID, request any, timeout int) (any, error)

func (MockNode) CallProcessID added in v1.999.330

func (n MockNode) CallProcessID(to gen.ProcessID, request any, timeout int) (any, error)

func (MockNode) CallWithPriority added in v1.999.330

func (n MockNode) CallWithPriority(to any, request any, priority gen.MessagePriority) (any, error)

func (MockNode) CallWithTimeout added in v1.999.330

func (n MockNode) CallWithTimeout(to any, request any, timeout int) (any, error)

func (MockNode) CertManager added in v1.999.330

func (n MockNode) CertManager() gen.CertManager

func (MockNode) Commercial added in v1.999.330

func (n MockNode) Commercial() []gen.Version

func (MockNode) Creation added in v1.999.330

func (n MockNode) Creation() int64

func (MockNode) Cron added in v1.999.330

func (n MockNode) Cron() gen.Cron

func (MockNode) Env added in v1.999.330

func (n MockNode) Env(name gen.Env) (any, bool)

func (MockNode) EnvDefault added in v1.999.330

func (n MockNode) EnvDefault(name gen.Env, def any) any

func (MockNode) EnvList added in v1.999.330

func (n MockNode) EnvList() map[gen.Env]any

func (MockNode) EventInfo added in v1.999.330

func (n MockNode) EventInfo(event gen.Event) (gen.EventInfo, error)

func (MockNode) EventListInfo added in v1.999.330

func (n MockNode) EventListInfo(timestamp int64, limit int, filter ...func(gen.EventInfo) bool) ([]gen.EventInfo, error)

func (MockNode) EventRangeInfo added in v1.999.330

func (n MockNode) EventRangeInfo(fn func(gen.EventInfo) bool) error

func (MockNode) FrameworkVersion added in v1.999.330

func (n MockNode) FrameworkVersion() gen.Version

func (MockNode) Info added in v1.999.330

func (n MockNode) Info() (gen.NodeInfo, error)

func (MockNode) Inspect added in v1.999.330

func (n MockNode) Inspect(target gen.PID, item ...string) (map[string]string, error)

func (MockNode) InspectMeta added in v1.999.330

func (n MockNode) InspectMeta(alias gen.Alias, item ...string) (map[string]string, error)

func (MockNode) IsAlive added in v1.999.330

func (n MockNode) IsAlive() bool

func (MockNode) Kill added in v1.999.330

func (n MockNode) Kill(pid gen.PID) error

func (MockNode) Log added in v1.999.330

func (n MockNode) Log() gen.Log

func (MockNode) LoggerAdd added in v1.999.330

func (n MockNode) LoggerAdd(name string, logger gen.LoggerBehavior, filter ...gen.LogLevel) error

func (MockNode) LoggerAddPID added in v1.999.330

func (n MockNode) LoggerAddPID(pid gen.PID, name string, filter ...gen.LogLevel) error

func (MockNode) LoggerDelete added in v1.999.330

func (n MockNode) LoggerDelete(name string)

func (MockNode) LoggerDeletePID added in v1.999.330

func (n MockNode) LoggerDeletePID(pid gen.PID)

func (MockNode) LoggerLevels added in v1.999.330

func (n MockNode) LoggerLevels(name string) []gen.LogLevel

func (MockNode) Loggers added in v1.999.330

func (n MockNode) Loggers() []string

func (MockNode) MakeRef added in v1.999.330

func (n MockNode) MakeRef() gen.Ref

func (MockNode) MakeRefWithDeadline added in v1.999.330

func (n MockNode) MakeRefWithDeadline(deadline int64) (gen.Ref, error)

func (MockNode) MetaInfo added in v1.999.330

func (n MockNode) MetaInfo(meta gen.Alias) (gen.MetaInfo, error)

func (MockNode) Name added in v1.999.330

func (n MockNode) Name() gen.Atom

func (*MockNode) Network added in v1.999.330

func (n *MockNode) Network() *MockNetwork

Network returns the test-config handle for the built-in mock network.

func (MockNode) NetworkStart added in v1.999.330

func (n MockNode) NetworkStart(options gen.NetworkOptions) error

func (MockNode) NetworkStop added in v1.999.330

func (n MockNode) NetworkStop() error

func (MockNode) OnApplicationInfo added in v1.999.330

func (n MockNode) OnApplicationInfo(fn func(name gen.Atom) (gen.ApplicationInfo, error))

func (MockNode) OnApplicationLoad added in v1.999.330

func (n MockNode) OnApplicationLoad(fn func(app gen.ApplicationBehavior, args ...any) (gen.Atom, error))

func (MockNode) OnApplicationProcessList added in v1.999.330

func (n MockNode) OnApplicationProcessList(fn func(name gen.Atom, limit int) ([]gen.PID, error))

func (MockNode) OnApplicationProcessListShortInfo added in v1.999.330

func (n MockNode) OnApplicationProcessListShortInfo(fn func(name gen.Atom, limit int) ([]gen.ProcessShortInfo, int, error))

func (MockNode) OnApplicationStart added in v1.999.330

func (n MockNode) OnApplicationStart(fn func(name gen.Atom, options gen.ApplicationOptions) error)

func (MockNode) OnApplicationStartPermanent added in v1.999.330

func (n MockNode) OnApplicationStartPermanent(fn func(name gen.Atom, options gen.ApplicationOptions) error)

func (MockNode) OnApplicationStartTemporary added in v1.999.330

func (n MockNode) OnApplicationStartTemporary(fn func(name gen.Atom, options gen.ApplicationOptions) error)

func (MockNode) OnApplicationStartTransient added in v1.999.330

func (n MockNode) OnApplicationStartTransient(fn func(name gen.Atom, options gen.ApplicationOptions) error)

func (MockNode) OnApplicationStop added in v1.999.330

func (n MockNode) OnApplicationStop(fn func(name gen.Atom) error)

func (MockNode) OnApplicationStopForce added in v1.999.330

func (n MockNode) OnApplicationStopForce(fn func(name gen.Atom) error)

func (MockNode) OnApplicationStopWithTimeout added in v1.999.330

func (n MockNode) OnApplicationStopWithTimeout(fn func(name gen.Atom, timeout time.Duration) error)

func (MockNode) OnApplicationUnload added in v1.999.330

func (n MockNode) OnApplicationUnload(fn func(name gen.Atom) error)

func (MockNode) OnApplications added in v1.999.330

func (n MockNode) OnApplications(fn func() []gen.Atom)

func (MockNode) OnApplicationsRunning added in v1.999.330

func (n MockNode) OnApplicationsRunning(fn func() []gen.Atom)

func (MockNode) OnCall added in v1.999.330

func (n MockNode) OnCall(to any) *CallStub

func (MockNode) OnCertManager added in v1.999.330

func (n MockNode) OnCertManager(fn func() gen.CertManager)

func (MockNode) OnCommercial added in v1.999.330

func (n MockNode) OnCommercial(fn func() []gen.Version)

func (MockNode) OnCreateAlias added in v1.999.330

func (n MockNode) OnCreateAlias() *CreateAliasStub

func (MockNode) OnCreation added in v1.999.330

func (n MockNode) OnCreation(fn func() int64)

func (MockNode) OnDemonitor added in v1.999.330

func (n MockNode) OnDemonitor(target any) *FailStub

func (MockNode) OnEnv added in v1.999.330

func (n MockNode) OnEnv(fn func(name gen.Env) (any, bool))

func (MockNode) OnEnvDefault added in v1.999.330

func (n MockNode) OnEnvDefault(fn func(name gen.Env, def any) any)

func (MockNode) OnEnvList added in v1.999.330

func (n MockNode) OnEnvList(fn func() map[gen.Env]any)

func (MockNode) OnEventInfo added in v1.999.330

func (n MockNode) OnEventInfo(fn func(event gen.Event) (gen.EventInfo, error))

func (MockNode) OnEventListInfo added in v1.999.330

func (n MockNode) OnEventListInfo(fn func(timestamp int64, limit int, filter ...func(gen.EventInfo) bool) ([]gen.EventInfo, error))

func (MockNode) OnEventRangeInfo added in v1.999.330

func (n MockNode) OnEventRangeInfo(fn func(fn func(gen.EventInfo) bool) error)

func (MockNode) OnForward added in v1.999.330

func (n MockNode) OnForward(to gen.PID) *FailStub

func (MockNode) OnFrameworkVersion added in v1.999.330

func (n MockNode) OnFrameworkVersion(fn func() gen.Version)

func (MockNode) OnInfo added in v1.999.330

func (n MockNode) OnInfo(fn func() (gen.NodeInfo, error))

func (MockNode) OnInspect added in v1.999.330

func (n MockNode) OnInspect(fn func(target gen.PID, item ...string) (map[string]string, error))

func (MockNode) OnInspectMeta added in v1.999.330

func (n MockNode) OnInspectMeta(fn func(alias gen.Alias, item ...string) (map[string]string, error))

func (MockNode) OnIsAlive added in v1.999.330

func (n MockNode) OnIsAlive(fn func() bool)

func (MockNode) OnKill added in v1.999.330

func (n MockNode) OnKill(fn func(pid gen.PID) error)
func (n MockNode) OnLink(target any) *FailStub

func (MockNode) OnLog added in v1.999.330

func (n MockNode) OnLog(fn func() gen.Log)

func (MockNode) OnLoggerAdd added in v1.999.330

func (n MockNode) OnLoggerAdd(fn func(name string, logger gen.LoggerBehavior, filter ...gen.LogLevel) error)

func (MockNode) OnLoggerAddPID added in v1.999.330

func (n MockNode) OnLoggerAddPID(fn func(pid gen.PID, name string, filter ...gen.LogLevel) error)

func (MockNode) OnLoggerDelete added in v1.999.330

func (n MockNode) OnLoggerDelete(fn func(name string))

func (MockNode) OnLoggerDeletePID added in v1.999.330

func (n MockNode) OnLoggerDeletePID(fn func(pid gen.PID))

func (MockNode) OnLoggerLevels added in v1.999.330

func (n MockNode) OnLoggerLevels(fn func(name string) []gen.LogLevel)

func (MockNode) OnLoggers added in v1.999.330

func (n MockNode) OnLoggers(fn func() []string)

func (MockNode) OnMakeRef added in v1.999.330

func (n MockNode) OnMakeRef(fn func() gen.Ref)

func (MockNode) OnMakeRefWithDeadline added in v1.999.330

func (n MockNode) OnMakeRefWithDeadline(fn func(deadline int64) (gen.Ref, error))

func (MockNode) OnMetaInfo added in v1.999.330

func (n MockNode) OnMetaInfo(fn func(meta gen.Alias) (gen.MetaInfo, error))

func (MockNode) OnMonitor added in v1.999.330

func (n MockNode) OnMonitor(target any) *FailStub

func (MockNode) OnName added in v1.999.330

func (n MockNode) OnName(fn func() gen.Atom)

func (MockNode) OnNetworkStart added in v1.999.330

func (n MockNode) OnNetworkStart(fn func(options gen.NetworkOptions) error)

func (MockNode) OnNetworkStop added in v1.999.330

func (n MockNode) OnNetworkStop(fn func() error)

func (MockNode) OnPID added in v1.999.330

func (n MockNode) OnPID(fn func() gen.PID)

func (MockNode) OnPeers added in v1.999.330

func (n MockNode) OnPeers(fn func() []gen.Atom)

func (MockNode) OnProcessInfo added in v1.999.330

func (n MockNode) OnProcessInfo(fn func(pid gen.PID) (gen.ProcessInfo, error))

func (MockNode) OnProcessList added in v1.999.330

func (n MockNode) OnProcessList(fn func() ([]gen.PID, error))

func (MockNode) OnProcessListShortInfo added in v1.999.330

func (n MockNode) OnProcessListShortInfo(fn func(start, limit int, filter ...func(gen.ProcessShortInfo) bool) ([]gen.ProcessShortInfo, error))

func (MockNode) OnProcessName added in v1.999.330

func (n MockNode) OnProcessName(fn func(pid gen.PID) (gen.Atom, error))

func (MockNode) OnProcessPID added in v1.999.330

func (n MockNode) OnProcessPID(fn func(name gen.Atom) (gen.PID, error))

func (MockNode) OnProcessRangeShortInfo added in v1.999.330

func (n MockNode) OnProcessRangeShortInfo(fn func(fn func(gen.ProcessShortInfo) bool) error)

func (MockNode) OnProcessState added in v1.999.330

func (n MockNode) OnProcessState(fn func(pid gen.PID) (gen.ProcessState, error))

func (MockNode) OnRegisterEvent added in v1.999.330

func (n MockNode) OnRegisterEvent(name gen.Atom) *RegisterEventStub

func (MockNode) OnRegisterName added in v1.999.330

func (n MockNode) OnRegisterName(fn func(name gen.Atom, pid gen.PID) error)

func (MockNode) OnRemoteSpawn added in v1.999.330

func (n MockNode) OnRemoteSpawn(node, name gen.Atom) *RemoteSpawnStub

func (MockNode) OnRemoveTracingAttribute added in v1.999.330

func (n MockNode) OnRemoveTracingAttribute(fn func(key string))

func (MockNode) OnSecurity added in v1.999.330

func (n MockNode) OnSecurity(fn func() gen.SecurityOptions)

func (MockNode) OnSend added in v1.999.330

func (n MockNode) OnSend(to any) *FailStub

func (MockNode) OnSendExit added in v1.999.330

func (n MockNode) OnSendExit(pid gen.PID) *FailStub

func (MockNode) OnSendExitMeta added in v1.999.330

func (n MockNode) OnSendExitMeta(meta gen.Alias) *FailStub

func (MockNode) OnSetCTRLC added in v1.999.330

func (n MockNode) OnSetCTRLC(fn func(enable bool))

func (MockNode) OnSetEnv added in v1.999.330

func (n MockNode) OnSetEnv(fn func(name gen.Env, value any))

func (MockNode) OnSetMetaLogLevel added in v1.999.330

func (n MockNode) OnSetMetaLogLevel(fn func(meta gen.Alias, level gen.LogLevel) error)

func (MockNode) OnSetMetaSendPriority added in v1.999.330

func (n MockNode) OnSetMetaSendPriority(fn func(meta gen.Alias, priority gen.MessagePriority) error)

func (MockNode) OnSetProcessCompression added in v1.999.330

func (n MockNode) OnSetProcessCompression(fn func(pid gen.PID, enabled bool) error)

func (MockNode) OnSetProcessCompressionLevel added in v1.999.330

func (n MockNode) OnSetProcessCompressionLevel(fn func(pid gen.PID, level gen.CompressionLevel) error)

func (MockNode) OnSetProcessCompressionThreshold added in v1.999.330

func (n MockNode) OnSetProcessCompressionThreshold(fn func(pid gen.PID, threshold int) error)

func (MockNode) OnSetProcessCompressionType added in v1.999.330

func (n MockNode) OnSetProcessCompressionType(fn func(pid gen.PID, ctype gen.CompressionType) error)

func (MockNode) OnSetProcessImportantDelivery added in v1.999.330

func (n MockNode) OnSetProcessImportantDelivery(fn func(pid gen.PID, important bool) error)

func (MockNode) OnSetProcessKeepNetworkOrder added in v1.999.330

func (n MockNode) OnSetProcessKeepNetworkOrder(fn func(pid gen.PID, order bool) error)

func (MockNode) OnSetProcessLogLevel added in v1.999.330

func (n MockNode) OnSetProcessLogLevel(fn func(pid gen.PID, level gen.LogLevel) error)

func (MockNode) OnSetProcessSendPriority added in v1.999.330

func (n MockNode) OnSetProcessSendPriority(fn func(pid gen.PID, priority gen.MessagePriority) error)

func (MockNode) OnSetProcessTracingSampler added in v1.999.330

func (n MockNode) OnSetProcessTracingSampler(fn func(pid gen.PID, sampler gen.TracingSampler) error)

func (MockNode) OnSetTracingAttribute added in v1.999.330

func (n MockNode) OnSetTracingAttribute(fn func(key, value string))

func (MockNode) OnSetTracingSampler added in v1.999.330

func (n MockNode) OnSetTracingSampler(fn func(sampler gen.TracingSampler) error)

func (MockNode) OnShortInfo added in v1.999.330

func (n MockNode) OnShortInfo(fn func() (gen.NodeShortInfo, error))

func (MockNode) OnSpawn added in v1.999.330

func (n MockNode) OnSpawn(factory gen.ProcessFactory) *SpawnStub

func (MockNode) OnSpawnMeta added in v1.999.330

func (n MockNode) OnSpawnMeta(sample gen.MetaBehavior) *SpawnMetaStub

func (MockNode) OnStop added in v1.999.330

func (n MockNode) OnStop(fn func())

func (MockNode) OnStopForce added in v1.999.330

func (n MockNode) OnStopForce(fn func())

func (MockNode) OnStopWithTimeout added in v1.999.330

func (n MockNode) OnStopWithTimeout(fn func(timeout time.Duration))

func (MockNode) OnTracingExporterAdd added in v1.999.330

func (n MockNode) OnTracingExporterAdd(fn func(name string, exporter gen.TracingBehavior, flags gen.TracingFlags) error)

func (MockNode) OnTracingExporterAddPID added in v1.999.330

func (n MockNode) OnTracingExporterAddPID(fn func(pid gen.PID, name string, flags gen.TracingFlags) error)

func (MockNode) OnTracingExporterDelete added in v1.999.330

func (n MockNode) OnTracingExporterDelete(fn func(name string))

func (MockNode) OnTracingExporterDeletePID added in v1.999.330

func (n MockNode) OnTracingExporterDeletePID(fn func(pid gen.PID))

func (MockNode) OnTracingExporterFlags added in v1.999.330

func (n MockNode) OnTracingExporterFlags(fn func(name string) gen.TracingFlags)

func (MockNode) OnTracingExporters added in v1.999.330

func (n MockNode) OnTracingExporters(fn func() []string)

func (MockNode) OnTracingSampler added in v1.999.330

func (n MockNode) OnTracingSampler(fn func() gen.TracingSampler)
func (n MockNode) OnUnlink(target any) *FailStub

func (MockNode) OnUnregisterEvent added in v1.999.330

func (n MockNode) OnUnregisterEvent(fn func(name gen.Atom) error)

func (MockNode) OnUnregisterName added in v1.999.330

func (n MockNode) OnUnregisterName(fn func(name gen.Atom) (gen.PID, error))

func (MockNode) OnUptime added in v1.999.330

func (n MockNode) OnUptime(fn func() int64)

func (MockNode) OnVersion added in v1.999.330

func (n MockNode) OnVersion(fn func() gen.Version)

func (MockNode) OnWait added in v1.999.330

func (n MockNode) OnWait(fn func())

func (MockNode) OnWaitWithTimeout added in v1.999.330

func (n MockNode) OnWaitWithTimeout(fn func(timeout time.Duration) error)

func (MockNode) PID added in v1.999.330

func (n MockNode) PID() gen.PID

func (MockNode) Peers added in v1.999.330

func (n MockNode) Peers() []gen.Atom

func (*MockNode) Prepare added in v1.999.330

func (n *MockNode) Prepare(factory gen.ProcessFactory, options gen.ProcessOptions, args ...any) *Subject

Prepare creates the process under test and returns its Subject WITHOUT running ProcessInit, so the actor's outbound operations during Init can be stubbed first (sub.OnCall, sub.OnSpawn, ...). Call sub.Run() to run ProcessInit with the args given here. Until Run, the process is not initialized: any delivery (SendMessage / Call / Deliver* / ...) fails loudly. Spawn is Prepare + Run.

func (*MockNode) PrepareRegister added in v1.999.330

func (n *MockNode) PrepareRegister(register gen.Atom, factory gen.ProcessFactory, options gen.ProcessOptions, args ...any) *Subject

PrepareRegister is Prepare with a registered name.

func (MockNode) ProcessInfo added in v1.999.330

func (n MockNode) ProcessInfo(pid gen.PID) (gen.ProcessInfo, error)

func (MockNode) ProcessList added in v1.999.330

func (n MockNode) ProcessList() ([]gen.PID, error)

func (MockNode) ProcessListShortInfo added in v1.999.330

func (n MockNode) ProcessListShortInfo(start, limit int, filter ...func(gen.ProcessShortInfo) bool) ([]gen.ProcessShortInfo, error)

func (MockNode) ProcessName added in v1.999.330

func (n MockNode) ProcessName(pid gen.PID) (gen.Atom, error)

func (MockNode) ProcessPID added in v1.999.330

func (n MockNode) ProcessPID(name gen.Atom) (gen.PID, error)

func (MockNode) ProcessRangeShortInfo added in v1.999.330

func (n MockNode) ProcessRangeShortInfo(fn func(gen.ProcessShortInfo) bool) error

func (MockNode) ProcessState added in v1.999.330

func (n MockNode) ProcessState(pid gen.PID) (gen.ProcessState, error)

func (MockNode) RegisterEvent added in v1.999.330

func (n MockNode) RegisterEvent(name gen.Atom, options gen.EventOptions) (gen.Ref, error)

func (MockNode) RegisterName added in v1.999.330

func (n MockNode) RegisterName(name gen.Atom, pid gen.PID) error

func (MockNode) RemoveTracingAttribute added in v1.999.330

func (n MockNode) RemoveTracingAttribute(key string)

func (MockNode) Security added in v1.999.330

func (n MockNode) Security() gen.SecurityOptions

func (MockNode) Send added in v1.999.330

func (n MockNode) Send(to any, message any) error

func (MockNode) SendEvent added in v1.999.330

func (n MockNode) SendEvent(name gen.Atom, token gen.Ref, options gen.MessageOptions, message any) error

func (MockNode) SendExit added in v1.999.330

func (n MockNode) SendExit(pid gen.PID, reason error) error

func (MockNode) SendWithPriority added in v1.999.330

func (n MockNode) SendWithPriority(to any, message any, priority gen.MessagePriority) error

func (MockNode) SetCTRLC added in v1.999.330

func (n MockNode) SetCTRLC(enable bool)

func (MockNode) SetEnv added in v1.999.330

func (n MockNode) SetEnv(name gen.Env, value any)

func (MockNode) SetMetaLogLevel added in v1.999.330

func (n MockNode) SetMetaLogLevel(meta gen.Alias, level gen.LogLevel) error

func (MockNode) SetMetaSendPriority added in v1.999.330

func (n MockNode) SetMetaSendPriority(meta gen.Alias, priority gen.MessagePriority) error

func (MockNode) SetProcessCompression added in v1.999.330

func (n MockNode) SetProcessCompression(pid gen.PID, enabled bool) error

func (MockNode) SetProcessCompressionLevel added in v1.999.330

func (n MockNode) SetProcessCompressionLevel(pid gen.PID, level gen.CompressionLevel) error

func (MockNode) SetProcessCompressionThreshold added in v1.999.330

func (n MockNode) SetProcessCompressionThreshold(pid gen.PID, threshold int) error

func (MockNode) SetProcessCompressionType added in v1.999.330

func (n MockNode) SetProcessCompressionType(pid gen.PID, ctype gen.CompressionType) error

func (MockNode) SetProcessImportantDelivery added in v1.999.330

func (n MockNode) SetProcessImportantDelivery(pid gen.PID, important bool) error

func (MockNode) SetProcessKeepNetworkOrder added in v1.999.330

func (n MockNode) SetProcessKeepNetworkOrder(pid gen.PID, order bool) error

func (MockNode) SetProcessLogLevel added in v1.999.330

func (n MockNode) SetProcessLogLevel(pid gen.PID, level gen.LogLevel) error

func (MockNode) SetProcessSendPriority added in v1.999.330

func (n MockNode) SetProcessSendPriority(pid gen.PID, priority gen.MessagePriority) error

func (MockNode) SetProcessTracingSampler added in v1.999.330

func (n MockNode) SetProcessTracingSampler(pid gen.PID, sampler gen.TracingSampler) error

func (MockNode) SetTracingAttribute added in v1.999.330

func (n MockNode) SetTracingAttribute(key, value string)

func (MockNode) SetTracingSampler added in v1.999.330

func (n MockNode) SetTracingSampler(sampler gen.TracingSampler) error

func (MockNode) ShortInfo added in v1.999.330

func (n MockNode) ShortInfo() (gen.NodeShortInfo, error)

func (*MockNode) Spawn added in v1.999.330

func (n *MockNode) Spawn(factory gen.ProcessFactory, options gen.ProcessOptions, args ...any) (*Subject, error)

Spawn creates the process under test on this node and runs its ProcessInit. Equivalent to Prepare followed by Run. Mirrors gen.Node.Spawn (factory, options, args...); pass gen.ProcessOptions{} for defaults.

func (*MockNode) SpawnRegister added in v1.999.330

func (n *MockNode) SpawnRegister(register gen.Atom, factory gen.ProcessFactory, options gen.ProcessOptions, args ...any) (*Subject, error)

SpawnRegister is Spawn with a registered name. Equivalent to PrepareRegister followed by Run. Mirrors gen.Node.SpawnRegister.

func (MockNode) Stop added in v1.999.330

func (n MockNode) Stop()

func (MockNode) StopForce added in v1.999.330

func (n MockNode) StopForce()

func (MockNode) StopWithTimeout added in v1.999.330

func (n MockNode) StopWithTimeout(timeout time.Duration)

func (MockNode) TracingExporterAdd added in v1.999.330

func (n MockNode) TracingExporterAdd(name string, exporter gen.TracingBehavior, flags gen.TracingFlags) error

func (MockNode) TracingExporterAddPID added in v1.999.330

func (n MockNode) TracingExporterAddPID(pid gen.PID, name string, flags gen.TracingFlags) error

func (MockNode) TracingExporterDelete added in v1.999.330

func (n MockNode) TracingExporterDelete(name string)

func (MockNode) TracingExporterDeletePID added in v1.999.330

func (n MockNode) TracingExporterDeletePID(pid gen.PID)

func (MockNode) TracingExporterFlags added in v1.999.330

func (n MockNode) TracingExporterFlags(name string) gen.TracingFlags

func (MockNode) TracingExporters added in v1.999.330

func (n MockNode) TracingExporters() []string

func (MockNode) TracingSampler added in v1.999.330

func (n MockNode) TracingSampler() gen.TracingSampler

func (MockNode) UnregisterEvent added in v1.999.330

func (n MockNode) UnregisterEvent(name gen.Atom) error

func (MockNode) UnregisterName added in v1.999.330

func (n MockNode) UnregisterName(name gen.Atom) (gen.PID, error)

func (MockNode) Uptime added in v1.999.330

func (n MockNode) Uptime() int64

func (MockNode) Version added in v1.999.330

func (n MockNode) Version() gen.Version

func (MockNode) Wait added in v1.999.330

func (n MockNode) Wait()

func (MockNode) WaitWithTimeout added in v1.999.330

func (n MockNode) WaitWithTimeout(timeout time.Duration) error

type MockRegistrar added in v1.999.330

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

MockRegistrar is the test-config handle for Network().Registrar().

func (*MockRegistrar) FailEvent added in v1.999.330

func (m *MockRegistrar) FailEvent(err error)

FailEvent stubs Registrar().Event() to return err.

func (*MockRegistrar) OnEvent added in v1.999.330

func (m *MockRegistrar) OnEvent(event gen.Event)

OnEvent stubs Registrar().Event() to return the given event (overriding the default).

func (*MockRegistrar) Resolver added in v1.999.330

func (m *MockRegistrar) Resolver() *MockResolver

Resolver returns the test-config handle for Registrar().Resolver().

type MockRemoteNode added in v1.999.330

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

MockRemoteNode is the test-config handle for Network().GetNode(name).

func (*MockRemoteNode) OnApplicationInfo added in v1.999.330

func (m *MockRemoteNode) OnApplicationInfo(name gen.Atom) *RemoteAppInfoReturn

OnApplicationInfo stubs RemoteNode.ApplicationInfo of the named application.

func (*MockRemoteNode) OnApplicationStart added in v1.999.330

func (m *MockRemoteNode) OnApplicationStart(name gen.Atom) *RemoteAppStartReturn

OnApplicationStart stubs RemoteNode.ApplicationStart* of the named application.

func (*MockRemoteNode) OnSpawn added in v1.999.330

func (m *MockRemoteNode) OnSpawn(name gen.Atom) *RemoteSpawnReturn

OnSpawn stubs RemoteNode.Spawn / SpawnRegister of the named remote factory.

type MockResolver added in v1.999.330

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

MockResolver is the test-config handle for Registrar().Resolver().

func (*MockResolver) OnResolve added in v1.999.330

func (m *MockResolver) OnResolve(name gen.Atom) *ResolveStub

OnResolve stubs Resolver().Resolve(name).

func (*MockResolver) OnResolveApplication added in v1.999.330

func (m *MockResolver) OnResolveApplication(name gen.Atom) *ResolveAppStub

OnResolveApplication stubs Resolver().ResolveApplication(name) (the common service-discovery seam).

type RegisterEventStub added in v1.999.330

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

RegisterEventStub stubs RegisterEvent (matched by event name).

func (*RegisterEventStub) Fail added in v1.999.330

func (s *RegisterEventStub) Fail(err error)

Fail makes RegisterEvent return err.

func (*RegisterEventStub) Return added in v1.999.330

func (s *RegisterEventStub) Return(token gen.Ref)

Return makes RegisterEvent return token.

type RemoteAppInfoReturn added in v1.999.330

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

RemoteAppInfoReturn configures what a remote ApplicationInfo returns.

func (*RemoteAppInfoReturn) Fail added in v1.999.330

func (s *RemoteAppInfoReturn) Fail(err error)

Fail makes ApplicationInfo return err.

func (*RemoteAppInfoReturn) Return added in v1.999.330

func (s *RemoteAppInfoReturn) Return(info gen.ApplicationInfo)

Return makes ApplicationInfo return info.

type RemoteAppStartReturn added in v1.999.330

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

RemoteAppStartReturn configures the outcome of a remote application start.

func (*RemoteAppStartReturn) Fail added in v1.999.330

func (s *RemoteAppStartReturn) Fail(err error)

Fail makes the remote application start return err (default is success).

type RemoteSpawnReturn added in v1.999.330

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

RemoteSpawnReturn configures what a remote Spawn of the factory returns.

func (*RemoteSpawnReturn) Fail added in v1.999.330

func (s *RemoteSpawnReturn) Fail(err error)

Fail makes the remote spawn return err.

func (*RemoteSpawnReturn) Return added in v1.999.330

func (s *RemoteSpawnReturn) Return(pid gen.PID)

Return makes the remote spawn return pid.

type RemoteSpawnStub added in v1.999.330

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

RemoteSpawnStub stubs RemoteSpawn / RemoteSpawnRegister (matched by node+name).

func (*RemoteSpawnStub) Fail added in v1.999.330

func (s *RemoteSpawnStub) Fail(err error)

Fail makes the remote spawn return err.

func (*RemoteSpawnStub) Return added in v1.999.330

func (s *RemoteSpawnStub) Return(pid gen.PID)

Return makes the remote spawn return pid.

type ResolveAppStub added in v1.999.330

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

ResolveAppStub configures what Resolver().ResolveApplication(name) returns.

func (*ResolveAppStub) Fail added in v1.999.330

func (s *ResolveAppStub) Fail(err error)

Fail makes ResolveApplication(name) return err.

func (*ResolveAppStub) Return added in v1.999.330

func (s *ResolveAppStub) Return(routes ...gen.ApplicationRoute)

Return makes ResolveApplication(name) return these application routes.

type ResolveStub added in v1.999.330

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

ResolveStub configures what Resolver().Resolve(name) returns.

func (*ResolveStub) Fail added in v1.999.330

func (s *ResolveStub) Fail(err error)

Fail makes Resolve(name) return err.

func (*ResolveStub) Return added in v1.999.330

func (s *ResolveStub) Return(routes ...gen.Route)

Return makes Resolve(name) return these routes.

type SpawnMetaStub added in v1.999.330

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

SpawnMetaStub stubs SpawnMeta (matched by the meta behavior's dynamic type).

func (*SpawnMetaStub) Fail added in v1.999.330

func (s *SpawnMetaStub) Fail(err error)

Fail makes SpawnMeta return err.

func (*SpawnMetaStub) Return added in v1.999.330

func (s *SpawnMetaStub) Return(alias gen.Alias)

Return makes SpawnMeta return alias.

type SpawnStub added in v1.999.330

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

SpawnStub stubs the process's outbound Spawn / SpawnRegister of a factory.

func (*SpawnStub) Fail added in v1.999.330

func (s *SpawnStub) Fail(err error)

Fail makes the spawn return err.

func (*SpawnStub) Return added in v1.999.330

func (s *SpawnStub) Return(pid gen.PID)

Return makes the spawn return pid.

func (*SpawnStub) ReturnFunc added in v1.999.330

func (s *SpawnStub) ReturnFunc(fn func() (gen.PID, error))

ReturnFunc computes the (pid, error) per matching spawn. A counter in the closure fails selectively, e.g. only the 3rd spawn of this factory.

type Subject added in v1.999.330

type Subject struct {
	*check.Asserter
	// contains filtered or unexported fields
}

Subject is the spawned process under test. It embeds *check.Asserter, so the whole Should* grammar is available directly (subject.ShouldSend(), etc.).

func Prepare added in v1.999.330

func Prepare(t testing.TB, factory gen.ProcessFactory, options gen.ProcessOptions, args ...any) *Subject

Prepare creates the process under test on a default mock node WITHOUT running ProcessInit, so the actor's Init-time outbound operations can be stubbed before Run. Shortcut for StartNode(t).Prepare(...); use StartNode(t, NodeOptions{...}) when you need to inject Network/Cron, set the node name, or seed env.

func PrepareRegister added in v1.999.330

func PrepareRegister(t testing.TB, register gen.Atom, factory gen.ProcessFactory, options gen.ProcessOptions, args ...any) *Subject

PrepareRegister creates the process under test with a registered name on a default mock node without running ProcessInit. Shortcut for StartNode(t, ...).PrepareRegister(...).

func Spawn

func Spawn(t testing.TB, factory gen.ProcessFactory, options gen.ProcessOptions, args ...any) (*Subject, error)

Spawn creates the process under test on a default mock node and runs its ProcessInit. Shortcut for StartNode(t).Spawn(...); use StartNode(t, NodeOptions{...}) when you need to inject Network/Cron, set the node name, or seed env.

func SpawnRegister added in v1.999.330

func SpawnRegister(t testing.TB, register gen.Atom, factory gen.ProcessFactory, options gen.ProcessOptions, args ...any) (*Subject, error)

SpawnRegister creates the process under test with a registered name on a default mock node and runs its ProcessInit. Shortcut for StartNode(t, ...).SpawnRegister(...).

func (*Subject) Behavior added in v1.999.330

func (s *Subject) Behavior() gen.ProcessBehavior

Behavior returns the process's behavior for state inspection.

func (*Subject) Call added in v1.999.330

func (s *Subject) Call(from gen.PID, request any) (any, error)

Call makes a synchronous request to the process (addressed by PID) and resolves the response from the process's reply: an immediate or deferred SendResponse, or an error (SendResponseError or an abnormal HandleCall return).

func (*Subject) CallAlias added in v1.999.330

func (s *Subject) CallAlias(alias gen.Alias, from gen.PID, request any) (any, error)

CallAlias makes a synchronous request addressed by alias. With an actor in split-handler mode this dispatches to HandleCallAlias.

func (*Subject) CallName added in v1.999.330

func (s *Subject) CallName(name gen.Atom, from gen.PID, request any) (any, error)

CallName makes a synchronous request addressed by registered name. With an actor in split-handler mode this dispatches to HandleCallName.

func (*Subject) CallWithDeadline added in v1.999.330

func (s *Subject) CallWithDeadline(from gen.PID, request any, deadline int64) (any, error)

CallWithDeadline makes a synchronous request whose reference carries an absolute unix deadline, the way a caller using CallWithTimeout builds it. A deadline that has already passed models a request that outlived the caller waiting for it: the actor sees ref.IsAlive() report false.

func (*Subject) CallWithPriority added in v1.999.330

func (s *Subject) CallWithPriority(from gen.PID, request any, priority gen.MessagePriority) (any, error)

CallWithPriority makes a synchronous request delivered at the given priority (Max -> Urgent, High -> System, Normal -> Main). Routers and pools dispatch a high-priority request to the admin HandleCall instead of routing/forwarding it.

func (*Subject) DeliverDown added in v1.999.330

func (s *Subject) DeliverDown(pid gen.PID, reason error) *Subject

DeliverDown delivers a MessageDownPID as a regular message (a monitored target died); use DeliverDownMessage for the other Down kinds.

func (*Subject) DeliverDownMessage added in v1.999.330

func (s *Subject) DeliverDownMessage(down any) *Subject

DeliverDownMessage delivers an arbitrary down message.

func (*Subject) DeliverEvent added in v1.999.330

func (s *Subject) DeliverEvent(event gen.Event, message any) *Subject

DeliverEvent delivers a pub/sub event to the process's HandleEvent.

func (*Subject) DeliverExit added in v1.999.330

func (s *Subject) DeliverExit(pid gen.PID, reason error) *Subject

DeliverExit delivers a MessageExitPID into the urgent queue.

func (*Subject) DeliverExitMessage added in v1.999.330

func (s *Subject) DeliverExitMessage(exit any) *Subject

DeliverExitMessage delivers an arbitrary exit message (ExitPID/ProcessID/Alias/ Event/Node) into the urgent queue.

func (*Subject) DeliverLog added in v1.999.330

func (s *Subject) DeliverLog(message gen.MessageLog) *Subject

DeliverLog delivers a log message to the process's HandleLog (the process must be registered as a logger). Arrives on the dedicated log queue.

func (*Subject) DeliverRegistrarEvent added in v1.999.330

func (s *Subject) DeliverRegistrarEvent(message any) *Subject

DeliverRegistrarEvent delivers a canonical gen.MessageRegistrar* message through the registrar event the actor subscribed to via Registrar().Event() (the built-in mock's default, or the one set by Network().Registrar().OnEvent). Convenience over DeliverEvent that the test does not need to hold the event value for.

func (*Subject) DeliverSpan added in v1.999.330

func (s *Subject) DeliverSpan(span gen.TracingSpan) *Subject

DeliverSpan delivers a tracing span to the process's HandleSpan (the process must be registered as a tracing exporter).

func (*Subject) Drain added in v1.999.330

func (s *Subject) Drain() int

Drain delivers every message the actor sent to itself, including the ones produced while draining, and returns how many it delivered. This is what a live node does on its own for the idiomatic "Init only posts to itself" actor.

Each round pushes the whole undelivered batch into the mailbox before running the process, so priority ordering works out as it does on a live node: an urgent self-send handled before a normal one queued earlier.

func (*Subject) FireCron added in v1.999.330

func (s *Subject) FireCron(name gen.Atom) *Subject

FireCron fires the named cron job, delivering its gen.MessageCron to the subject (the common message-to-self cron action). The job must have been added (and not disabled) via Node().Cron().AddJob, mirroring the real scheduler firing only registered jobs. Spawn/remote-spawn cron actions are out of scope here.

func (*Subject) FireTimers added in v1.999.330

func (s *Subject) FireTimers() int

FireTimers delivers every scheduled (and not cancelled) SendAfter message whose target is the process under test into its mailbox, in scheduling order, and runs the process. Timers targeting other processes are marked fired but not delivered (the message would leave the process, which the harness only records). Returns the number of timers fired.

func (*Subject) Inspect added in v1.999.330

func (s *Subject) Inspect(from gen.PID, items ...string) (map[string]string, error)

Inspect sends an inspection request to the process and resolves the map the process replies with via HandleInspect. from is the inspecting PID (the real Inspect sets the message From to the caller's PID); pass gen.PID{} when the actor ignores it. Mirrors the runtime: the request arrives on the urgent queue and the reply is a SendResponse carrying the result map.

func (*Subject) Node added in v1.999.330

func (s *Subject) Node() *MockNode

Node returns the mock node backing the process under test. Use it to override node methods (sub.Node().OnProcessInfo(...)) or to inspect node state directly (sub.Node().ProcessList()). It wraps the same node the process sees via its Node().

func (*Subject) OnAliases added in v1.999.330

func (s *Subject) OnAliases(fn func() []gen.Alias)

func (*Subject) OnApplication added in v1.999.330

func (s *Subject) OnApplication(fn func() gen.Application)

func (*Subject) OnBehavior added in v1.999.330

func (s *Subject) OnBehavior(fn func() gen.ProcessBehavior)

func (*Subject) OnBehaviorName added in v1.999.330

func (s *Subject) OnBehaviorName(fn func() string)

func (*Subject) OnCall added in v1.999.330

func (a *Subject) OnCall(to any) *CallStub

OnCall stubs the process's outbound Call to `to` (PID/ProcessID/Alias/Atom).

func (*Subject) OnClearTracingSpanAttributes added in v1.999.330

func (s *Subject) OnClearTracingSpanAttributes(fn func())

func (*Subject) OnCompression added in v1.999.330

func (s *Subject) OnCompression(fn func() bool)

func (*Subject) OnCompressionLevel added in v1.999.330

func (s *Subject) OnCompressionLevel(fn func() gen.CompressionLevel)

func (*Subject) OnCompressionThreshold added in v1.999.330

func (s *Subject) OnCompressionThreshold(fn func() int)

func (*Subject) OnCompressionType added in v1.999.330

func (s *Subject) OnCompressionType(fn func() gen.CompressionType)

func (*Subject) OnCreateAlias added in v1.999.330

func (a *Subject) OnCreateAlias() *CreateAliasStub

OnCreateAlias stubs the process's CreateAlias.

func (*Subject) OnDeleteAlias added in v1.999.330

func (s *Subject) OnDeleteAlias(fn func(alias gen.Alias) error)

func (*Subject) OnDemonitor added in v1.999.330

func (a *Subject) OnDemonitor(target any) *FailStub

OnDemonitor stubs a Demonitor of target to fail.

func (*Subject) OnEnv added in v1.999.330

func (s *Subject) OnEnv(fn func(name gen.Env) (any, bool))

func (*Subject) OnEnvDefault added in v1.999.330

func (s *Subject) OnEnvDefault(fn func(name gen.Env, def any) any)

func (*Subject) OnEnvList added in v1.999.330

func (s *Subject) OnEnvList(fn func() map[gen.Env]any)

func (*Subject) OnEvents added in v1.999.330

func (s *Subject) OnEvents(fn func() []gen.Atom)

func (*Subject) OnForward added in v1.999.330

func (a *Subject) OnForward(to gen.PID) *FailStub

OnForward stubs a Forward to the target PID to fail.

func (*Subject) OnImportantDelivery added in v1.999.330

func (s *Subject) OnImportantDelivery(fn func() bool)

func (*Subject) OnInfo added in v1.999.330

func (s *Subject) OnInfo(fn func() (gen.ProcessInfo, error))

func (*Subject) OnInspect added in v1.999.330

func (s *Subject) OnInspect(fn func(target gen.PID, item ...string) (map[string]string, error))

func (*Subject) OnInspectMeta added in v1.999.330

func (s *Subject) OnInspectMeta(fn func(meta gen.Alias, item ...string) (map[string]string, error))

func (*Subject) OnKeepNetworkOrder added in v1.999.330

func (s *Subject) OnKeepNetworkOrder(fn func() bool)

func (*Subject) OnLeader added in v1.999.330

func (s *Subject) OnLeader(fn func() gen.PID)
func (a *Subject) OnLink(target any) *FailStub

OnLink stubs a Link to target to fail.

func (*Subject) OnLinkEvent added in v1.999.330

func (a *Subject) OnLinkEvent(event gen.Event) *EventSubscribeStub

OnLinkEvent stubs LinkEvent of the given event.

func (*Subject) OnLog added in v1.999.330

func (s *Subject) OnLog(fn func() gen.Log)

func (*Subject) OnMailbox added in v1.999.330

func (s *Subject) OnMailbox(fn func() gen.ProcessMailbox)

func (*Subject) OnMetaInfo added in v1.999.330

func (s *Subject) OnMetaInfo(fn func(meta gen.Alias) (gen.MetaInfo, error))

func (*Subject) OnMonitor added in v1.999.330

func (a *Subject) OnMonitor(target any) *FailStub

OnMonitor stubs a Monitor of target to fail.

func (*Subject) OnMonitorEvent added in v1.999.330

func (a *Subject) OnMonitorEvent(event gen.Event) *EventSubscribeStub

OnMonitorEvent stubs MonitorEvent of the given event.

func (*Subject) OnName added in v1.999.330

func (s *Subject) OnName(fn func() gen.Atom)

func (*Subject) OnNode added in v1.999.330

func (s *Subject) OnNode(fn func() gen.Node)

func (*Subject) OnPID added in v1.999.330

func (s *Subject) OnPID(fn func() gen.PID)

func (*Subject) OnParent added in v1.999.330

func (s *Subject) OnParent(fn func() gen.PID)

func (*Subject) OnPropagatingTrace added in v1.999.330

func (s *Subject) OnPropagatingTrace(fn func() gen.Tracing)

func (*Subject) OnRegisterEvent added in v1.999.330

func (a *Subject) OnRegisterEvent(name gen.Atom) *RegisterEventStub

OnRegisterEvent stubs RegisterEvent of the given name.

func (*Subject) OnRegisterName added in v1.999.330

func (s *Subject) OnRegisterName(fn func(name gen.Atom) error)

func (*Subject) OnRemoteSpawn added in v1.999.330

func (a *Subject) OnRemoteSpawn(node, name gen.Atom) *RemoteSpawnStub

OnRemoteSpawn stubs RemoteSpawn of name on node.

func (*Subject) OnRemoveTracingAttribute added in v1.999.330

func (s *Subject) OnRemoveTracingAttribute(fn func(key string))

func (*Subject) OnSend added in v1.999.330

func (a *Subject) OnSend(to any) *FailStub

OnSend stubs a Send to `to` to fail.

func (*Subject) OnSendExit added in v1.999.330

func (a *Subject) OnSendExit(pid gen.PID) *FailStub

OnSendExit stubs a SendExit to pid to fail.

func (*Subject) OnSendExitMeta added in v1.999.330

func (a *Subject) OnSendExitMeta(meta gen.Alias) *FailStub

OnSendExitMeta stubs a SendExitMeta to the meta alias to fail.

func (*Subject) OnSendPriority added in v1.999.330

func (s *Subject) OnSendPriority(fn func() gen.MessagePriority)

func (*Subject) OnSendResponse added in v1.999.330

func (a *Subject) OnSendResponse(to any) *FailStub

OnSendResponse stubs the response to a call from `to` to fail. The real node answers gen.ErrResponseIgnored when the caller is no longer waiting for it.

func (*Subject) OnSendTracingSpan added in v1.999.330

func (s *Subject) OnSendTracingSpan(fn func(span gen.TracingSpan))

func (*Subject) OnSetCompression added in v1.999.330

func (s *Subject) OnSetCompression(fn func(enabled bool) error)

func (*Subject) OnSetCompressionLevel added in v1.999.330

func (s *Subject) OnSetCompressionLevel(fn func(level gen.CompressionLevel) error)

func (*Subject) OnSetCompressionThreshold added in v1.999.330

func (s *Subject) OnSetCompressionThreshold(fn func(threshold int) error)

func (*Subject) OnSetCompressionType added in v1.999.330

func (s *Subject) OnSetCompressionType(fn func(ctype gen.CompressionType) error)

func (*Subject) OnSetEnv added in v1.999.330

func (s *Subject) OnSetEnv(fn func(name gen.Env, value any))

func (*Subject) OnSetImportantDelivery added in v1.999.330

func (s *Subject) OnSetImportantDelivery(fn func(important bool) error)

func (*Subject) OnSetKeepNetworkOrder added in v1.999.330

func (s *Subject) OnSetKeepNetworkOrder(fn func(order bool) error)

func (*Subject) OnSetProcessKind added in v1.999.330

func (s *Subject) OnSetProcessKind(fn func(kind gen.ProcessKind) error)

func (*Subject) OnSetPropagatingTrace added in v1.999.330

func (s *Subject) OnSetPropagatingTrace(fn func(t gen.Tracing))

func (*Subject) OnSetSendPriority added in v1.999.330

func (s *Subject) OnSetSendPriority(fn func(priority gen.MessagePriority) error)

func (*Subject) OnSetTracingAttribute added in v1.999.330

func (s *Subject) OnSetTracingAttribute(fn func(key, value string))

func (*Subject) OnSetTracingSampler added in v1.999.330

func (s *Subject) OnSetTracingSampler(fn func(sampler gen.TracingSampler) error)

func (*Subject) OnSetTracingSpanAttribute added in v1.999.330

func (s *Subject) OnSetTracingSpanAttribute(fn func(key, value string))

func (*Subject) OnShortInfo added in v1.999.330

func (s *Subject) OnShortInfo(fn func() (gen.ProcessShortInfo, error))

func (*Subject) OnSpawn added in v1.999.330

func (a *Subject) OnSpawn(factory gen.ProcessFactory) *SpawnStub

OnSpawn stubs Spawn/SpawnRegister of the given factory.

func (*Subject) OnSpawnMeta added in v1.999.330

func (a *Subject) OnSpawnMeta(sample gen.MetaBehavior) *SpawnMetaStub

OnSpawnMeta stubs SpawnMeta of a behavior of the same dynamic type as sample.

func (*Subject) OnState added in v1.999.330

func (s *Subject) OnState(fn func() gen.ProcessState)

func (*Subject) OnTracingAttributes added in v1.999.330

func (s *Subject) OnTracingAttributes(fn func() []gen.TracingAttribute)

func (*Subject) OnTracingSampler added in v1.999.330

func (s *Subject) OnTracingSampler(fn func() gen.TracingSampler)
func (a *Subject) OnUnlink(target any) *FailStub

OnUnlink stubs an Unlink of target to fail.

func (*Subject) OnUnregisterEvent added in v1.999.330

func (s *Subject) OnUnregisterEvent(fn func(name gen.Atom) error)

func (*Subject) OnUnregisterName added in v1.999.330

func (s *Subject) OnUnregisterName(fn func() error)

func (*Subject) OnUptime added in v1.999.330

func (s *Subject) OnUptime(fn func() int64)

func (*Subject) PID added in v1.999.330

func (s *Subject) PID() gen.PID

PID returns the process's PID.

func (*Subject) PrepareMeta added in v1.999.330

func (s *Subject) PrepareMeta(behavior gen.MetaBehavior, options gen.MetaOptions) *MetaSubject

PrepareMeta instantiates a meta-process behavior under the parent actor and returns its MetaSubject WITHOUT running Init, so the meta's Init-time egress can be stubbed first on its own scope (ms.OnSend, ms.OnSpawnMeta). Call ms.Run() to run Init. The meta's stubs are isolated from the parent actor; its records still land in the shared journal.

func (*Subject) Reason added in v1.999.330

func (s *Subject) Reason() error

Reason returns the termination reason (nil while running).

func (*Subject) Run added in v1.999.330

func (s *Subject) Run() error

Run runs the prepared process's ProcessInit (with the args passed to Prepare), transitioning it from Init to Running. Spawn calls this for you; after Prepare call it explicitly. Calling Run twice fails loudly.

func (*Subject) SendMessage added in v1.999.330

func (s *Subject) SendMessage(from gen.PID, message any) *Subject

SendMessage delivers a regular message to the process (addressed by PID).

func (*Subject) SendMessageAlias added in v1.999.330

func (s *Subject) SendMessageAlias(alias gen.Alias, from gen.PID, message any) *Subject

SendMessageAlias delivers a regular message addressed by alias. With an actor in split-handler mode this dispatches to HandleMessageAlias.

func (*Subject) SendMessageName added in v1.999.330

func (s *Subject) SendMessageName(name gen.Atom, from gen.PID, message any) *Subject

SendMessageName delivers a regular message addressed by registered name. With an actor in split-handler mode this dispatches to HandleMessageName.

func (*Subject) SendMessageWithPriority added in v1.999.330

func (s *Subject) SendMessageWithPriority(from gen.PID, message any, priority gen.MessagePriority) *Subject

SendMessageWithPriority delivers a message into the queue for the given priority (Max -> Urgent, High -> System, Normal -> Main).

func (*Subject) SpawnMeta added in v1.999.330

func (s *Subject) SpawnMeta(behavior gen.MetaBehavior, options gen.MetaOptions) (*MetaSubject, error)

SpawnMeta instantiates a meta-process behavior under the parent actor, runs its Init, and returns a MetaSubject to drive it. Equivalent to PrepareMeta followed by Run. Init runs in the pre-running state (Send and Spawn are allowed, SendResponse is not, matching the runtime). If Init fails the meta is left terminated and the error is returned.

func (*Subject) Step added in v1.999.330

func (s *Subject) Step() bool

Step delivers one message the actor sent to itself and has not received yet, the highest-priority one first, and reports whether it delivered one. Messages the actor sent elsewhere are left alone: the harness only records those.

func (*Subject) Terminated added in v1.999.330

func (s *Subject) Terminated() bool

Terminated reports whether the process has terminated.

Jump to

Keyboard shortcuts

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