harmonia-utils-test

Crates.ioharmonia-utils-test
lib.rsharmonia-utils-test
version0.0.0-alpha.0
created_at2026-01-23 17:25:34.763208+00
updated_at2026-01-23 17:25:34.763208+00
descriptionTest utilities for Harmonia (proptest strategies, macros)
homepagehttps://github.com/nix-community/harmonia
repositoryhttps://github.com/nix-community/harmonia.git
max_upload_size
id2065107
size26,851
team-os-internal-crates-owners (github:coreos:team-os-internal-crates-owners)

documentation

README

harmonia-utils-test

Proptest strategies and test macros for property-based testing.

Overview

This crate provides proptest strategies for generating test data and assertion macros for property-based testing of Harmonia crates. It should only be used as a dev-dependency.

Contents

  • arb_filename / arb_path - Strategies for generating valid filenames and paths
  • arb_byte_string - Strategy for generating arbitrary byte strings
  • arb_duration / arb_system_time - Strategies for time values
  • helpers::Union - Weighted union of proptest strategies

Example

use harmonia_utils_test::{arb_path, arb_byte_string};
use proptest::prelude::*;

proptest! {
    #[test]
    fn roundtrip_path(path in arb_path()) {
        let encoded = encode(&path);
        let decoded = decode(&encoded)?;
        prop_assert_eq!(path, decoded);
    }

    #[test]
    fn roundtrip_bytes(data in arb_byte_string()) {
        let compressed = compress(&data);
        let decompressed = decompress(&compressed)?;
        prop_assert_eq!(data, decompressed);
    }
}

Strategies

Strategy Generates
arb_filename() Valid filenames (no . or ..)
arb_path() Valid relative paths
arb_file_component() Single path component
arb_byte_string() Arbitrary bytes::Bytes
arb_duration() std::time::Duration values
arb_system_time() System time as duration

Key Characteristics

  • Dev-dependency only (not needed at runtime)
  • Generates valid data that satisfies invariants
Commit count: 0

cargo fmt