From c238aa1b4645b832888d06e759f9212d7c4d9eda Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 18 Aug 2022 13:50:13 +0100 Subject: [PATCH] Add YAML spec docs about matching errors (#89370) 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 0544ec2bf8a61..f2f04e219afdf 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 @@ -320,8 +320,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: