Skip to content

Commit

Permalink
cmd/speccheck: disable error check
Browse files Browse the repository at this point in the history
  • Loading branch information
fjl committed Jan 28, 2024
1 parent c045879 commit 1518d67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions cmd/speccheck/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ func checkSpec(methods map[string]*methodSchema, rts []*roundTrip, re *regexp.Re
return fmt.Errorf("missing required parameter %s.param[%d]", rt.method, i)
}
if err := validate(&method.params[i].schema, rt.params[i], fmt.Sprintf("%s.param[%d]", rt.method, i)); err != nil {
return fmt.Errorf("unable to validate parameter: %s", err)
return fmt.Errorf("unable to validate parameter in %s: %s", rt.name, err)
}
}
if err := validate(&method.result.schema, rt.response, fmt.Sprintf("%s.result", rt.method)); err != nil {
if rt.response.Result == nil && rt.response.Error != nil {
// skip validation of errors, they haven't been standardized
continue
}
if err := validate(&method.result.schema, rt.response.Result, fmt.Sprintf("%s.result", rt.method)); err != nil {
// Print out the value and schema if there is an error to further debug.
buf, _ := json.Marshal(method.result.schema)
fmt.Println(string(buf))
fmt.Println(string(rt.response))
fmt.Println(string(rt.response.Result))
fmt.Println()
return fmt.Errorf("invalid result %s\n%#v", rt.name, err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/speccheck/roundtrips.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type roundTrip struct {
method string
name string
params [][]byte
response []byte
response *jsonrpcMessage
}

// readRtts walks a root directory and parses round trip HTTP exchanges
Expand Down Expand Up @@ -99,7 +99,7 @@ func readTest(testname string, filename string) ([]*roundTrip, error) {
if err != nil {
return nil, fmt.Errorf("unable to parse params: %s %v", err, req.Params)
}
rts = append(rts, &roundTrip{req.Method, testname, params, resp.Result})
rts = append(rts, &roundTrip{req.Method, testname, params, &resp})
req = nil
default:
return nil, fmt.Errorf("invalid line in test: %s", line)
Expand Down

0 comments on commit 1518d67

Please sign in to comment.