ion-cli icon indicating copy to clipboard operation
ion-cli copied to clipboard

Consider adding an `ion schema test` command

Open popematt opened this issue 11 months ago • 0 comments

This could solve https://github.com/amazon-ion/ion-schema/issues/37.

One possible API design would be something like this. (Most of these options are copied from ion schema validate since this is basically just a different interface around the same validation logic.)

ion schema test [OPTIONS] <type>

Options:
  -L                      Interpret each line as a separate input.
  -T                      Interpret each top level value as a separate input.
  -o, --output <output>   Output file [default: STDOUT]
  -h, --help              Print help
  -V, --version           Print version

Test Cases:
--valid             One or more files containing test values that should be valid for the type being tested
--invalid           One or more files containing test values that should be invalid for the type being tested

Selecting a schema:
      --empty <version>            An empty schema document for the specified Ion Schema version. [default: 2.0] [possible values: 1.0,
                                   2.0]
  -f, --schema-file <schema-file>  A schema file
      --schema-text <schema-text>  The Ion text contents of a schema document.
      --id <schema-id>             The ID of a schema to load from one of the configured authorities.
  -A, --authority <directory>      The root(s) of the file system authority(s). Authorities are only required if your schema needs to
                                   import a type from another schema or if you are loading a schema using the --id option.

Alternately, an implementation could accept a test suite using the same or similar DSL as ion-schema-tests.

Dependency note—to provide a useful test report, we need Element to expose its location in the serialized data.

popematt avatar Jan 14 '25 01:01 popematt