Cooper.Conformance (Cooper v0.7.0)

Copy Markdown View Source

This implementation's adapter for the Cooper Conformance Suite: a JSON request in, a JSON answer out (mix cooper.conformance REQUEST ANSWER).

The suite (libs_prx/cooper_conformance in the Praxis repository, run by its assize library) holds every CASC implementation to the same cases. Each case asks for one operation, load, on a document file; this answers with the loaded configuration in the suite's typed JSON, or with the category (CASC.md §9.5) of the error that refused it.

What every adapter loads with

The suite fixes the environment and the extension points, so a case can use them and every implementation sees the same: the variables in @env, no .env file, the document's own directory as the root, the resolvers echo (answers its payload) and fail (refuses), the tag twice (doubles an integer, repeats a string) and the import scheme mem: (mem:base, mem:vars).

Values

Every value travels in the suite's typed JSON: {"integer": "42"}, {"float": "2.0"}, {"keyword": "info"}, {"tuple": [...]}, {"map": [[key, value], ...]}, arrays, and strings, booleans and null as they are. What CASC has and Praxis notation has no literal for is a tuple tagged with a namespaced keyword -- casc/duration, casc/bytes, casc/secret, casc/module, casc/float, casc/ipv4, casc/ipv6, casc/date, casc/time, casc/local-date-time, casc/date-time -- which no CASC atom can be, so a tag never reads as a tuple a document wrote.

Summary

Functions

The answer to a decoded request: one result per case, in order.

value, as this implementation holds a loaded configuration, in the suite's typed JSON.

Reads the request at request_path and writes the answer to answer_path.

Functions

answer(map)

@spec answer(map()) :: map()

The answer to a decoded request: one result per case, in order.

encode(value)

@spec encode(term()) :: term()

value, as this implementation holds a loaded configuration, in the suite's typed JSON.

run(request_path, answer_path)

@spec run(Path.t(), Path.t()) :: :ok | {:error, term()}

Reads the request at request_path and writes the answer to answer_path.

:ok, or {:error, reason} when the request cannot be read or the answer cannot be written. A case that fails is an answer, not an error.