MCPcopy
hub / github.com/larksuite/cli / TestScanForSafety_ScanError_FailOpen

Function TestScanForSafety_ScanError_FailOpen

internal/output/emit_test.go:105–119  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func TestScanForSafety_ScanError_FailOpen(t *testing.T) {
106 t.Setenv("LARKSUITE_CLI_CONTENT_SAFETY_MODE", "block")
107 mp := &mockProvider{name: "mock", err: errors.New("scan broke")}
108 extcs.Register(mp)
109 defer extcs.Register(nil)
110
111 var buf bytes.Buffer
112 result := ScanForSafety("lark-cli im +test", map[string]any{}, &buf)
113 if result.Blocked {
114 t.Error("scan error should fail-open, not block")
115 }
116 if !strings.Contains(buf.String(), "scan error") {
117 t.Errorf("expected warning on stderr, got: %s", buf.String())
118 }
119}
120
121func TestScanForSafety_SlowProvider_Timeout_FailOpen(t *testing.T) {
122 t.Setenv("LARKSUITE_CLI_CONTENT_SAFETY_MODE", "block")

Callers

nothing calls this directly

Calls 5

ScanForSafetyFunction · 0.85
RegisterMethod · 0.45
ErrorMethod · 0.45
ContainsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected