Files
Agent-System-Backend/internal/runtime/permission_ask_test.go
T
weichen f1302ed5b3 Enable canonical versioned Go module consumption
Why: Allow consumers to download an immutable module revision without nested source checkouts or local path replacements.

Evidence: SELF package tests and the prior canonical-path rejection are recorded in the Dev dependency-workspace task card; remote consumption is replayed against the committed candidate.

Impact: Change the module identity and its Go imports while preserving API behavior. Existing historical submodule revisions remain buildable.

Refs: Versioned dependencies U1/U3; feature/dependency-workspace
2026-10-13 15:47:16 +00:00

36 lines
995 B
Go

package runtime
import (
"context"
"testing"
nruntime "git-ssh.u1680832.nyat.app/weichen/Agent-Native.git/runtime"
agentllm "git-ssh.u1680832.nyat.app/weichen/Agent-Native.git/runtime/llm"
)
// PermissionAskOf 只在宿主实现内核级询问时接线;否则返回 nil,
// 内核保持「ask 按拒绝处理」的旧行为。
func TestPermissionAskOfOptional(t *testing.T) {
type plain struct{ RunCtx }
if got := PermissionAskOf(plain{}); got != nil {
t.Fatal("plain rc returned a non-nil ask port, want nil")
}
}
func TestPermissionAskOfWired(t *testing.T) {
type asker struct{ RunCtx }
wired := PermissionAskOf(askStub{})
if wired == nil {
t.Fatal("wired rc returned nil")
}
if v := wired(context.Background(), agentllm.ToolCall{Name: "run_shell"}); !v.Allow {
t.Fatalf("verdict = %+v", v)
}
}
type askStub struct{ RunCtx }
func (askStub) PermissionAsk(ctx context.Context, call agentllm.ToolCall) nruntime.AskVerdict {
return nruntime.AskVerdict{Allow: true}
}