WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
package sandbox
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestDefaultConfig(t *testing.T) {
|
||||
config := DefaultConfig()
|
||||
|
||||
if config.Type != SandboxTypeDisabled {
|
||||
t.Errorf("Expected default type to be disabled, got %s", config.Type)
|
||||
}
|
||||
|
||||
if config.DefaultTimeout != DefaultTimeout {
|
||||
t.Errorf("Expected default timeout %v, got %v", DefaultTimeout, config.DefaultTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateConfig(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
config *Config
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "nil config",
|
||||
config: nil,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "valid disabled config",
|
||||
config: &Config{
|
||||
Type: SandboxTypeDisabled,
|
||||
DefaultTimeout: 30 * time.Second,
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "invalid type",
|
||||
config: &Config{
|
||||
Type: "invalid",
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "removed local type",
|
||||
config: &Config{
|
||||
Type: "local",
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "negative timeout",
|
||||
config: &Config{
|
||||
Type: SandboxTypeDisabled,
|
||||
DefaultTimeout: -1 * time.Second,
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := ValidateConfig(tt.config)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("ValidateConfig() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewManager(t *testing.T) {
|
||||
config := DefaultConfig()
|
||||
config.Type = SandboxTypeDisabled
|
||||
|
||||
manager, err := NewManager(config)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create manager: %v", err)
|
||||
}
|
||||
|
||||
if manager.GetType() != SandboxTypeDisabled {
|
||||
t.Errorf("Expected type disabled, got %s", manager.GetType())
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewDisabledManager(t *testing.T) {
|
||||
manager := NewDisabledManager()
|
||||
|
||||
if manager.GetType() != SandboxTypeDisabled {
|
||||
t.Errorf("Expected type disabled, got %s", manager.GetType())
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
_, err := manager.Execute(ctx, &ExecuteConfig{
|
||||
Script: "/some/script.sh",
|
||||
})
|
||||
|
||||
if err != ErrSandboxDisabled {
|
||||
t.Errorf("Expected ErrSandboxDisabled, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsNamedSandboxBackendType(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
raw string
|
||||
want bool
|
||||
}{
|
||||
{"cube", true},
|
||||
{"e2b", true},
|
||||
{"docker", true},
|
||||
{"local", false},
|
||||
{"disabled", false},
|
||||
{"", false},
|
||||
} {
|
||||
if got := IsNamedSandboxBackendType(tc.raw); got != tc.want {
|
||||
t.Fatalf("IsNamedSandboxBackendType(%q) = %v, want %v", tc.raw, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteResultHelpers(t *testing.T) {
|
||||
successResult := &ExecuteResult{
|
||||
ExitCode: 0,
|
||||
Stdout: "output",
|
||||
}
|
||||
if !successResult.IsSuccess() {
|
||||
t.Error("Expected IsSuccess() to return true for exit code 0")
|
||||
}
|
||||
|
||||
failResult := &ExecuteResult{
|
||||
ExitCode: 1,
|
||||
Stderr: "error",
|
||||
}
|
||||
if failResult.IsSuccess() {
|
||||
t.Error("Expected IsSuccess() to return false for exit code 1")
|
||||
}
|
||||
|
||||
killedResult := &ExecuteResult{
|
||||
ExitCode: 0,
|
||||
Killed: true,
|
||||
}
|
||||
if killedResult.IsSuccess() {
|
||||
t.Error("Expected IsSuccess() to return false when killed")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user