MCPcopy Create free account
hub / github.com/astercloud/aster / TestLocalSandbox_CommandStats

Function TestLocalSandbox_CommandStats

pkg/sandbox/local_test.go:483–510  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

481}
482
483func TestLocalSandbox_CommandStats(t *testing.T) {
484 tmpDir, err := os.MkdirTemp("", "sandbox-test-*")
485 if err != nil {
486 t.Fatalf("failed to create temp dir: %v", err)
487 }
488 defer func() { _ = os.RemoveAll(tmpDir) }()
489
490 sb, err := NewLocalSandbox(&LocalSandboxConfig{
491 WorkDir: tmpDir,
492 })
493 if err != nil {
494 t.Fatalf("failed to create sandbox: %v", err)
495 }
496
497 // Execute echo multiple times
498 for range 5 {
499 _, _ = sb.Exec(context.Background(), "echo test", nil)
500 }
501
502 stats := sb.GetCommandStats()
503 echoStats, ok := stats["echo"]
504 if !ok {
505 t.Fatal("expected stats for echo command")
506 }
507 if echoStats.TotalCalls != 5 {
508 t.Errorf("expected 5 calls, got %d", echoStats.TotalCalls)
509 }
510}
511
512func TestLocalSandbox_BlockedCommands(t *testing.T) {
513 tmpDir, err := os.MkdirTemp("", "sandbox-test-*")

Callers

nothing calls this directly

Calls 3

ExecMethod · 0.95
GetCommandStatsMethod · 0.95
NewLocalSandboxFunction · 0.85

Tested by

no test coverage detected