mock

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package mock provides a mock implementation of the runtime.Runtime interface for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockRuntime

type MockRuntime struct {

	// Hooks for customizing behavior in tests
	OnCreate        func(ctx context.Context, config *runtime.SandboxConfig) (*types.Sandbox, error)
	OnStart         func(ctx context.Context, sandboxID string) error
	OnStop          func(ctx context.Context, sandboxID string) error
	OnDestroy       func(ctx context.Context, sandboxID string) error
	OnExec          func(ctx context.Context, sandboxID string, req *types.ExecRequest) (*types.ExecResult, error)
	OnCreateSession func(ctx context.Context, sandboxID string, config *types.SessionConfig) (*types.Session, error)
	OnSessionExec   func(ctx context.Context, sessionID string, req *types.SessionExecRequest) (*types.ExecResult, error)
	// contains filtered or unexported fields
}

MockRuntime is a mock implementation of runtime.RuntimeWithSession for testing.

func New

func New() *MockRuntime

New creates a new MockRuntime.

func (*MockRuntime) Create

func (m *MockRuntime) Create(ctx context.Context, config *runtime.SandboxConfig) (*types.Sandbox, error)

Create creates a new sandbox but does not start it.

func (*MockRuntime) CreateSession

func (m *MockRuntime) CreateSession(ctx context.Context, sandboxID string, config *types.SessionConfig) (*types.Session, error)

CreateSession creates a new shell session within a sandbox.

func (*MockRuntime) Destroy

func (m *MockRuntime) Destroy(ctx context.Context, sandboxID string) error

Destroy destroys a sandbox, releasing all resources.

func (*MockRuntime) DestroySession

func (m *MockRuntime) DestroySession(ctx context.Context, sessionID string) error

DestroySession destroys a session and kills all its child processes.

func (*MockRuntime) Exec

func (m *MockRuntime) Exec(ctx context.Context, sandboxID string, req *types.ExecRequest) (*types.ExecResult, error)

Exec executes a command in the sandbox and returns the result.

func (*MockRuntime) ExecStream

func (m *MockRuntime) ExecStream(ctx context.Context, sandboxID string, req *types.ExecRequest, output chan<- []byte) error

ExecStream executes a command and streams output.

func (*MockRuntime) Get

func (m *MockRuntime) Get(ctx context.Context, sandboxID string) (*types.Sandbox, error)

Get retrieves information about a sandbox.

func (*MockRuntime) GetSession

func (m *MockRuntime) GetSession(ctx context.Context, sessionID string) (*types.Session, error)

GetSession retrieves information about a session.

func (*MockRuntime) List

func (m *MockRuntime) List(ctx context.Context) ([]*types.Sandbox, error)

List returns all sandboxes managed by this runtime.

func (*MockRuntime) ListSessions

func (m *MockRuntime) ListSessions(ctx context.Context, sandboxID string) ([]*types.Session, error)

ListSessions returns all sessions for a sandbox.

func (*MockRuntime) Name

func (m *MockRuntime) Name() string

Name returns the name of this runtime implementation.

func (*MockRuntime) SessionExec

func (m *MockRuntime) SessionExec(ctx context.Context, sessionID string, req *types.SessionExecRequest) (*types.ExecResult, error)

SessionExec executes a command within a session, preserving state.

func (*MockRuntime) SessionExecStream

func (m *MockRuntime) SessionExecStream(ctx context.Context, sessionID string, req *types.SessionExecRequest, output chan<- []byte) error

SessionExecStream executes a command within a session and streams output.

func (*MockRuntime) Start

func (m *MockRuntime) Start(ctx context.Context, sandboxID string) error

Start starts a previously created sandbox.

func (*MockRuntime) Stop

func (m *MockRuntime) Stop(ctx context.Context, sandboxID string) error

Stop stops a running sandbox without destroying it.

Jump to

Keyboard shortcuts

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