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

Function TestWrapDocInputFileErr

shortcuts/doc/doc_errors_test.go:320–336  ·  view source on GitHub ↗

TestWrapDocInputFileErr pins that a --file stat/read failure becomes a typed validation error tagged with the --file param and the cause preserved, so an agent knows which flag to fix even though the shared helper is flag-agnostic.

(t *testing.T)

Source from the content-addressed store, hash-verified

318// validation error tagged with the --file param and the cause preserved, so an
319// agent knows which flag to fix even though the shared helper is flag-agnostic.
320func TestWrapDocInputFileErr(t *testing.T) {
321 raw := errors.New("no such file or directory")
322 got := wrapDocInputFileErr(raw, "file not found")
323 var ve *errs.ValidationError
324 if !errors.As(got, &ve) {
325 t.Fatalf("error type = %T, want *errs.ValidationError (%v)", got, got)
326 }
327 if ve.Subtype != errs.SubtypeInvalidArgument {
328 t.Errorf("subtype = %q, want %q", ve.Subtype, errs.SubtypeInvalidArgument)
329 }
330 if ve.Param != "--file" {
331 t.Errorf("param = %q, want %q", ve.Param, "--file")
332 }
333 if !errors.Is(got, raw) {
334 t.Error("cause not chained: errors.Is(got, raw) == false")
335 }
336}
337
338func TestValidateUpdateV2Contract(t *testing.T) {
339 cases := []struct {

Callers

nothing calls this directly

Calls 4

wrapDocInputFileErrFunction · 0.85
AsMethod · 0.80
IsMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected