From 0ef2054cf4e94bd147ba0c1585e16c028b10953a Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 18 Aug 2022 14:22:05 +0100 Subject: [PATCH] Add YAML spec docs about matching errors (#89370) (#89460) It's not obvious that a YAML test with a `catch` stanza also permits `match` blocks to assert things about the structure of the error response, but this structure may be an important part of the API spec. This commit adds this info to the docs about YAML tests. --- .../resources/rest-api-spec/test/README.asciidoc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/README.asciidoc b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/README.asciidoc index 8dd1e80be0747..b1f3b774d0485 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/README.asciidoc +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/README.asciidoc @@ -308,8 +308,15 @@ be caught and tested. For instance: catch: missing get: index: test - type: test + type: test id: 1 + +# And, optionally, you can assert on the contents of the precise contents of the error message: + + - match: { error.type: "illegal_argument_exception" } + - match: { error.reason: "The request contained an illegal argument" } + - match: { error.caused_by.reason: "The argument was illegal because ..." } + - match: { error.root_cause.0.type: "illegal_argument_exception" } .... The argument to `catch` can be any of: