Skip to content

Add property-based tests for AppType serde/schema roundtrip and load_image_overrides #548

Description

@phaedrus1992

Summary

Follow-up from the pre-pr-review pass on sprint #544's PR (AppType custom JsonSchema impl,
load_image_overrides() env-var parsing). property-test-gap-finder identified three
serialization/parsing code paths with only example-based coverage that would benefit from
proptest (already a workspace dependency):

  1. AppType serde roundtrip + alias resolution (crates/servarr-crds/src/v1alpha1/spec.rs):
    deserialize(serialize(v)) == v for all variants, deserialize("Overseerr") == AppType::Seerr,
    and as_str()/wire-format consistency -- currently only one variant (Sonarr) is roundtrip-tested.
  2. JsonSchema generation drift (same file): completeness (schema ⊇ AppType::ALL
    LEGACY_APP_TYPE_ALIASES), idempotence, no duplicates, and that every schema enum value is a
    valid serde input. A hand-written exactness test was added in sprint Sprint: Overseerr→Seerr 1.2→1.3 upgrade-path hardening #544's PR
    (schema_enum_length_matches_all_variants_plus_legacy_aliases,
    every_legacy_app_type_alias_deserializes) but property-based generation would cover more of
    the space (e.g. duplicate detection, idempotence across repeated calls).
  3. load_image_overrides() env-var parsing (crates/servarr-operator/src/context.rs):
    arbitrary subsets of DEFAULT_IMAGE_<APP>_* env vars (all present/all missing/mixed,
    tag-without-repo, repo-without-tag, explicit seerr vars coexisting with the legacy
    overseerr fallback) -- currently covered by several targeted example tests but not
    systematically across the combination space.

Why

These are exactly the "high value from PBT" pattern per nbl-dev:property-based-testing:
serialization, parsing, and schema generation with combinatorial input spaces. The AppType alias
and schema logic in particular gates CRD admission validation for the whole operator -- drift here
either silently rejects valid manifests or silently accepts values the operator can't parse.

Scope

  • crates/servarr-crds/tests/crd_tests.rs (or a new proptest_apptype.rs): roundtrip + schema
    completeness/idempotence properties.
  • crates/servarr-operator/src/context.rs::tests: env-var combination properties for
    load_image_overrides().

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions