From 540988486902c9b49bd3c0c22451a5aafbd1af15 Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Tue, 20 Aug 2024 14:38:33 +0100 Subject: [PATCH] encoding/jsonschema: add docs about test file conventions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes it clearer how to write jsonschema test cases. It was intended to be part of https://cuelang.org/cl/1199743 but was accidentally omitted from that CL. Signed-off-by: Roger Peppe Change-Id: I2e5f92526ace4949551b0976cdf9c3d9313e0502 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200066 Reviewed-by: Daniel Martí TryBot-Result: CUEcueckoo Unity-Result: CUE porcuepine --- encoding/jsonschema/decode_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/encoding/jsonschema/decode_test.go b/encoding/jsonschema/decode_test.go index edf77d68e18..3c9472c2357 100644 --- a/encoding/jsonschema/decode_test.go +++ b/encoding/jsonschema/decode_test.go @@ -45,6 +45,20 @@ import ( // JSON schema to CUE and compares it against the output. // // Set CUE_UPDATE=1 to update test files with the corresponding output. +// +// Each test extracts the JSON Schema from a schema file (either +// schema.json or schema.yaml) and writes the result to +// out/decode/extract. +// +// If there are any files in the "test" directory in the txtar, each one +// is extracted and validated against the extracted schema. If the file +// name starts with "err-" it is expected to fail, otherwise it is +// expected to succeed. +// +// The #noverify tag in the txtar header causes verification and +// instance tests to be skipped. +// +// The #openapi tag in the txtar header enables OpenAPI extraction mode. func TestDecode(t *testing.T) { test := cuetxtar.TxTarTest{ Root: "./testdata",