MCPcopy Index your code
hub / github.com/larksuite/cli / requireJSONInputValidationError

Function requireJSONInputValidationError

internal/cmdutil/json_test.go:18–36  ·  view source on GitHub ↗

requireJSONInputValidationError asserts err is a typed *errs.ValidationError with subtype invalid_argument, exit code 2 (legacy ErrValidation parity), and the offending flag recorded as Param.

(t *testing.T, err error, wantParam string)

Source from the content-addressed store, hash-verified

16// with subtype invalid_argument, exit code 2 (legacy ErrValidation parity),
17// and the offending flag recorded as Param.
18func requireJSONInputValidationError(t *testing.T, err error, wantParam string) {
19 t.Helper()
20 var valErr *errs.ValidationError
21 if !errors.As(err, &valErr) {
22 t.Fatalf("expected *errs.ValidationError, got %T: %v", err, err)
23 }
24 if valErr.Subtype != errs.SubtypeInvalidArgument {
25 t.Errorf("subtype = %q, want %q", valErr.Subtype, errs.SubtypeInvalidArgument)
26 }
27 if valErr.Param != wantParam {
28 t.Errorf("param = %q, want %q", valErr.Param, wantParam)
29 }
30 if got := output.ExitCodeOf(err); got != output.ExitValidation {
31 t.Errorf("exit code = %d, want %d (ExitValidation, legacy parity)", got, output.ExitValidation)
32 }
33 if valErr.Cause == nil {
34 t.Error("expected the underlying parse/resolve error attached as Cause")
35 }
36}
37
38func TestParseOptionalBody(t *testing.T) {
39 fio := &localfileio.LocalFileIO{}

Callers 2

TestParseOptionalBodyFunction · 0.85
TestParseJSONMapFunction · 0.85

Calls 3

ExitCodeOfFunction · 0.92
AsMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected