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

Function requireFileValidationError

internal/cmdutil/fileupload_test.go:27–49  ·  view source on GitHub ↗

requireFileValidationError asserts err is a typed *errs.ValidationError with the expected subtype, exit code 2 (legacy ErrValidation parity), and a param diagnostic referencing --file (either Param or one of Params).

(t *testing.T, err error, wantSubtype errs.Subtype)

Source from the content-addressed store, hash-verified

25// the expected subtype, exit code 2 (legacy ErrValidation parity), and a
26// param diagnostic referencing --file (either Param or one of Params).
27func requireFileValidationError(t *testing.T, err error, wantSubtype errs.Subtype) *errs.ValidationError {
28 t.Helper()
29 var valErr *errs.ValidationError
30 if !errors.As(err, &valErr) {
31 t.Fatalf("expected *errs.ValidationError, got %T: %v", err, err)
32 }
33 if valErr.Subtype != wantSubtype {
34 t.Errorf("subtype = %q, want %q", valErr.Subtype, wantSubtype)
35 }
36 if got := output.ExitCodeOf(err); got != output.ExitValidation {
37 t.Errorf("exit code = %d, want %d (ExitValidation, legacy parity)", got, output.ExitValidation)
38 }
39 mentionsFile := valErr.Param == "--file"
40 for _, p := range valErr.Params {
41 if p.Name == "--file" {
42 mentionsFile = true
43 }
44 }
45 if !mentionsFile {
46 t.Errorf("expected --file in Param/Params, got Param=%q Params=%v", valErr.Param, valErr.Params)
47 }
48 return valErr
49}
50
51func TestParseFileFlag(t *testing.T) {
52 tests := []struct {

Callers 2

TestValidateFileFlagFunction · 0.85
TestBuildFormdataFunction · 0.85

Calls 2

ExitCodeOfFunction · 0.92
AsMethod · 0.80

Tested by

no test coverage detected