Module testing

Module testing 

Source
Expand description

Some helpful utilities for testing. This module is only available if the test-tools feature is enabled. Its main feature is allowing the use of prebuilt scaffolds for testing.

See the README in the testing directory of bindle for more information on scaffolding structure. All loading functions will load scaffolds by default from $CARGO_MANIFEST_DIR/tests/scaffolds. However, this directory can be configured by setting the BINDLE_SCAFFOLD_DIR environment variable to your desired path. All functions will panic if they encounter an error to make it easier on users (so they don’t have to handle the errors in their tests in the exact same way)

Structs§

MockKeyStore
ParcelInfo
A struct containing the SHA of the data and the data as bytes
RawScaffold
A scaffold loaded from disk, containing the raw bytes for all files in the bindle.
Scaffold
A scaffold loaded from disk, containing the bindle object representations for all files in the bindle (except for the parcels themselves, as they can be binary data).

Constants§

SCAFFOLD_DIR_ENV
The environment variable name used for setting the scaffolds directory

Functions§

load_all_files
Loads all scaffolds in the scaffolds directory, returning them as a hashmap with the directory name as the key and a RawScaffold as a value. There is not an equivalent for loading all scaffolds as a Scaffold object, because some of them may be invalid on will not deserialize properly
setup
Returns a file Provider implementation configured with a temporary directory, strict Search implementation, and a mock key store for use in testing API endpoints
setup_embedded
Returns an embedded Provider implementation configured with a temporary directory, strict Search implementation, and a mock key store for use in testing API endpoints