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

Function TestGetToolRiskLevel

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

Source from the content-addressed store, hash-verified

251}
252
253func TestGetToolRiskLevel(t *testing.T) {
254 highRiskTool := &mockToolWithAnnotations{name: "high", annotations: AnnotationsDestructiveWrite}
255 lowRiskTool := &mockToolWithAnnotations{name: "low", annotations: AnnotationsSafeReadOnly}
256 noAnnotationTool := &mockToolWithoutAnnotations{name: "none"}
257
258 if GetToolRiskLevel(highRiskTool) != RiskLevelHigh {
259 t.Errorf("High risk tool level = %d, want %d", GetToolRiskLevel(highRiskTool), RiskLevelHigh)
260 }
261 if GetToolRiskLevel(lowRiskTool) != RiskLevelSafe {
262 t.Errorf("Low risk tool level = %d, want %d", GetToolRiskLevel(lowRiskTool), RiskLevelSafe)
263 }
264 if GetToolRiskLevel(noAnnotationTool) != RiskLevelMedium {
265 t.Errorf("No annotation tool level = %d, want %d", GetToolRiskLevel(noAnnotationTool), RiskLevelMedium)
266 }
267}
268
269func TestAnnotationsNilSafety(t *testing.T) {
270 // 测试 nil annotations 的安全性

Callers

nothing calls this directly

Calls 1

GetToolRiskLevelFunction · 0.85

Tested by

no test coverage detected