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

Function TestPredefinedAnnotations

pkg/tools/annotations_test.go:132–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

130}
131
132func TestPredefinedAnnotations(t *testing.T) {
133 // 测试预定义注解的正确性
134 tests := []struct {
135 name string
136 ann *ToolAnnotations
137 readOnly bool
138 destructive bool
139 openWorld bool
140 minRisk int
141 }{
142 {"SafeReadOnly", AnnotationsSafeReadOnly, true, false, false, RiskLevelSafe},
143 {"SafeWrite", AnnotationsSafeWrite, false, false, false, RiskLevelLow},
144 {"DestructiveWrite", AnnotationsDestructiveWrite, false, true, false, RiskLevelHigh},
145 {"Execution", AnnotationsExecution, false, true, true, RiskLevelHigh}, // OpenWorld = true (可能访问网络)
146 {"NetworkRead", AnnotationsNetworkRead, true, false, true, RiskLevelLow},
147 {"NetworkWrite", AnnotationsNetworkWrite, false, false, true, RiskLevelMedium},
148 }
149
150 for _, tt := range tests {
151 t.Run(tt.name, func(t *testing.T) {
152 if tt.ann.ReadOnly != tt.readOnly {
153 t.Errorf("ReadOnly = %v, want %v", tt.ann.ReadOnly, tt.readOnly)
154 }
155 if tt.ann.Destructive != tt.destructive {
156 t.Errorf("Destructive = %v, want %v", tt.ann.Destructive, tt.destructive)
157 }
158 if tt.ann.OpenWorld != tt.openWorld {
159 t.Errorf("OpenWorld = %v, want %v", tt.ann.OpenWorld, tt.openWorld)
160 }
161 if tt.ann.RiskLevel < tt.minRisk {
162 t.Errorf("RiskLevel = %d, want >= %d", tt.ann.RiskLevel, tt.minRisk)
163 }
164 })
165 }
166}
167
168// mockToolWithAnnotations 带注解的模拟工具
169type mockToolWithAnnotations struct {

Callers

nothing calls this directly

Calls 1

RunMethod · 0.45

Tested by

no test coverage detected