Documentation
¶
Overview ¶
Package mock provides a mock implementation of the runtime.Runtime interface for testing.
Index ¶
- type MockRuntime
- func (m *MockRuntime) Create(ctx context.Context, config *runtime.SandboxConfig) (*types.Sandbox, error)
- func (m *MockRuntime) CreateSession(ctx context.Context, sandboxID string, config *types.SessionConfig) (*types.Session, error)
- func (m *MockRuntime) Destroy(ctx context.Context, sandboxID string) error
- func (m *MockRuntime) DestroySession(ctx context.Context, sessionID string) error
- func (m *MockRuntime) Exec(ctx context.Context, sandboxID string, req *types.ExecRequest) (*types.ExecResult, error)
- func (m *MockRuntime) ExecStream(ctx context.Context, sandboxID string, req *types.ExecRequest, ...) error
- func (m *MockRuntime) Get(ctx context.Context, sandboxID string) (*types.Sandbox, error)
- func (m *MockRuntime) GetSession(ctx context.Context, sessionID string) (*types.Session, error)
- func (m *MockRuntime) List(ctx context.Context) ([]*types.Sandbox, error)
- func (m *MockRuntime) ListSessions(ctx context.Context, sandboxID string) ([]*types.Session, error)
- func (m *MockRuntime) Name() string
- func (m *MockRuntime) SessionExec(ctx context.Context, sessionID string, req *types.SessionExecRequest) (*types.ExecResult, error)
- func (m *MockRuntime) SessionExecStream(ctx context.Context, sessionID string, req *types.SessionExecRequest, ...) error
- func (m *MockRuntime) Start(ctx context.Context, sandboxID string) error
- func (m *MockRuntime) Stop(ctx context.Context, sandboxID string) error
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 (*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) GetSession ¶
GetSession retrieves information about a session.
func (*MockRuntime) ListSessions ¶
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.