Skip to main content

Module test_support

Module test_support 

Source
Available on crate feature test-support only.
Expand description

Mock Thunderstore server, package index, and archives for tests. A mock Thunderstore for tests: an HTTP server that serves a small package index and real package archives, so the install pipeline runs end to end with no network access.

The index has five packages, each downloaded from /dl/<archive>.zip:

  • Owner-ModA and Owner-ModB 1.0.0, with no dependencies.
  • Owner-ModC 1.0.0, which depends on Owner-ModA-1.0.0.
  • Owner-ModD at 1.0.0 and a newer 2.0.0, from ModD-1.0.0.zip and ModD-2.0.0.zip.
  • denikson-BepInExPack_Valheim 5.4.2200, a real mod-loader identifier whose archive is shaped by loader_zip.

Each mod archive ships a DLL named after its package (ModA.dll), so a test can tell whose files landed where.

Every version has a readme except Owner-ModB, which answers 404 like a package Thunderstore has no readme for.

use thunderstore_engine::test_support::MockThunderstore;

let mock = MockThunderstore::start_async().await;
let client = mock.client_builder().cache_dir("/tmp/cache").build()?;
let index = client.get_manifest().await?;

assert_eq!(index.len(), 5);

Re-exports§

pub use mockito;

Structs§

MockThunderstore
A running mock Thunderstore serving index_json and every archive it names.

Constants§

PACKAGE_INDEX_PATH
Path the package index is served from.

Functions§

index_json
The package index described in the module docs, with every download URL under server_url.
loader_zip
A mod-loader archive shaped like denikson-BepInExPack_Valheim: its payload sits under the rootFolder the bundled ecosystem names for that package, so an install strips the wrapper and the files land at the target root.
mod_zip
A mod archive with a manifest at version and one DLL, plugins/ModA.dll, which the install rules route to BepInEx/plugins/<Owner-Name>/.
mod_zip_with
mod_zip with the DLL named dll_name.
readme
The readme markdown the mock serves for name at version, such as "# ModA 1.0.0\n\nA mod.".
readme_path
Path a version’s readme is served from, as Thunderstore lays it out.