The ain API for hegel-clj.
The ain API for hegel-clj.
We make the client accessible as a dynamic variable, so that generators can access it without having to thread arguments through every phase of generation.
We make the client accessible as a dynamic variable, so that generators can access it without having to thread arguments through every phase of generation.
As another convenience, we store the current test case stream ID so you don't have to thread it between test cases and calls to generate.
As another convenience, we store the current test case stream ID so you don't have to thread it between test cases and calls to generate.
As a convenience, we keep a global client around and automatically spin it upon the first request.
As a convenience, we keep a global client around and automatically spin it upon the first request.
(collection-more? collection-id)See client/collection-more?
See client/collection-more?
(collection-reject! collection-id)See client/collection-reject!
See client/collection-reject!
(final?)Returns true iff we're in the final pass of a test case.
Returns true iff we're in the final pass of a test case.
(finfo & args)Logging macro. Calls core.logging/info, but only when in a final test run.
Logging macro. Calls core.logging/info, but only when in a final test run.
(fpprint & args)Like clojure pprint, but only when in a final test run.
Like clojure pprint, but only when in a final test run.
(fprn & args)Like clojure prn, but only when in a final test run.
Like clojure prn, but only when in a final test run.
(fwarn & args)Logging macro. Calls core.logging/warn, but only when in a final test run.
Logging macro. Calls core.logging/warn, but only when in a final test run.
(gen schema)Generates a random value from the provided schema. Use hegel-clj.gen to
construct a schema, like so:
(gen (gen/one-of (gen/boolean) (gen/integer)))
Generates a random value from the provided schema. Use `hegel-clj.gen` to
construct a schema, like so:
(gen (gen/one-of (gen/boolean) (gen/integer)))(gen-global-span-type!)Generates a new global span. This is available at macroexpand time.
Generates a new global span. This is available at macroexpand time.
(gen-span-type!)Returns a fresh span type for the current client.
Returns a fresh span type for the current client.
(new-collection! opts)See client/new-collection!
See client/new-collection!
The Core can generate span types, but we can also generate them globally (e.g. at macroexpand time). We use this in g/let to start spans. Global spans are negative.
The Core can generate span types, but we can also generate them globally (e.g. at macroexpand time). We use this in g/let to start spans. Global spans are negative.
(run-test! opts & body)Macro form of run-test!*; takes a body, rather than a function.
Macro form of run-test!*; takes a body, rather than a function.
(run-test!* opts case-fn)Runs a test. This version is more functional; for a more convenient, stateful version, use deftest. Options are:
:test-cases The number of test cases to run
:seed A random seed
:derandomize If true, and seed is not set, derives a deterministic
seed from database-key
:database-key A stable database key for this test
:database A path to the DB directory
:suppress-health-check A vector of health check keywords to suppress:
any of :test-cases-too-large, :filter-too-much,
:too-slow, :large-initial-test-case
Takes a function (case-fn) which will be invoked approximately test-cases
times, with zero arguments. This function can call (gen/int) etc. to
generate values, and should return a map which explains whether the case was
valid or not:
{:status :valid}
{:status :invalid}
{:status :interesting
:origin "..."}
Returns a map describing the results of the test, of the form:
:passed? Did all tests pass?)
:test-cases How many test cases were executed?
:valid-test-cases How many of them were valid
:invalid-test-cases How many of them were invalid
:interesting-test-cases How many of them were interesting (e.g. a bug)
:seed The random seed used
:flaky? Hegel thought this test was non-deterministic
:health-check-failure? Did a health check fail during the test?
May also throw an exception map like {:type :hegel-error, :message "..."}.
Runs a test. This version is more functional; for a more convenient,
stateful version, use deftest. Options are:
:test-cases The number of test cases to run
:seed A random seed
:derandomize If true, and seed is not set, derives a deterministic
seed from database-key
:database-key A stable database key for this test
:database A path to the DB directory
:suppress-health-check A vector of health check keywords to suppress:
any of :test-cases-too-large, :filter-too-much,
:too-slow, :large-initial-test-case
Takes a function `(case-fn)` which will be invoked approximately `test-cases`
times, with zero arguments. This function can call `(gen/int)` etc. to
generate values, and should return a map which explains whether the case was
valid or not:
{:status :valid}
{:status :invalid}
{:status :interesting
:origin "..."}
Returns a map describing the results of the test, of the form:
:passed? Did all tests pass?)
:test-cases How many test cases were executed?
:valid-test-cases How many of them were valid
:invalid-test-cases How many of them were invalid
:interesting-test-cases How many of them were interesting (e.g. a bug)
:seed The random seed used
:flaky? Hegel thought this test was non-deterministic
:health-check-failure? Did a health check fail during the test?
May also throw an exception map like {:type :hegel-error, :message "..."}.(sample n & body)Evaluates body up to n times, returning a vector of results. Useful for debugging generators.
Evaluates body up to n times, returning a vector of results. Useful for debugging generators.
(sample* n f)Samples up to n values from the provided function (f), which presumably
calls gen. Helpful for debugging generators.
Samples up to `n` values from the provided function `(f)`, which presumably calls `gen`. Helpful for debugging generators.
(start-span! span-type)Starts a span of the given type on the current client.
Starts a span of the given type on the current client.
(stop-span!)Stops a span on the current client.
Stops a span on the current client.
(when-final & body)Evaluates body only if this is a final test case. Helpful for logging.
Evaluates body only if this is a final test case. Helpful for logging.
(with-span & body)Evaluates body with a span. Generates a unique span type at macroexpand time.
Evaluates body with a span. Generates a unique span type at macroexpand time.
(with-span* span-type & body)Evaluates body with a span of the given type. If the body throws, I'm not sure what to do; I'm going to try closing the span, but I imagine that's probably asking for trouble sometimes.
Evaluates body with a span of the given type. If the body throws, I'm not sure *what* to do; I'm going to try closing the span, but I imagine that's probably asking for trouble sometimes.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |