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

Function TestAnnotationsNilSafety

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

Source from the content-addressed store, hash-verified

267}
268
269func TestAnnotationsNilSafety(t *testing.T) {
270 // 测试 nil annotations 的安全性
271 var ann *ToolAnnotations = nil
272
273 // GetAnnotations 应该对 nil 工具返回默认注解
274 defaultAnn := GetAnnotations(&mockToolWithoutAnnotations{name: "test"})
275 if defaultAnn == nil {
276 t.Error("GetAnnotations should never return nil")
277 }
278
279 // 测试 nil annotations 的方法(应该 panic 或返回默认值)
280 // 这里我们验证非 nil 注解的行为
281 ann = &ToolAnnotations{}
282 if ann.IsSafeForAutoApproval() {
283 // 默认空注解不应该被认为是安全的(ReadOnly = false)
284 t.Error("Empty annotations should not be safe for auto approval")
285 }
286}

Callers

nothing calls this directly

Calls 3

IsSafeForAutoApprovalMethod · 0.95
GetAnnotationsFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected