Skip to content

Test: cover the pack metadata compression fallback path #96

Done

Description

@blocksmith314

Problem

#95 reworked how pack stores metadata: when compression is enabled and shrinks the metadata, the compressed scratch buffer is written; when compression is disabled or does not shrink, the raw meta_buffer is written instead.

The compressed path is covered by PackLayout.CompressesMetadataAboveThreshold (metadata > 1 MiB, header says LZ4, round trip). The fallback path (compression enabled but LZ4 returns 0 or does not shrink) has no direct test. A regression there could write the wrong buffer or header type/size and still pass the current suite.

Proposal

  • Make the buffer-selection logic testable, for example by factoring it into a small helper that takes the Compress result and returns the stored pointer/size and header fields; then unit-test both branches.
  • Or add a test-only compressor injection point so a test can force the "not shrinking" result.
  • Alternatively, construct a fixture whose metadata LZ4 cannot shrink, if that can be made deterministic.

Acceptance

  • A test exercises the fallback branch and checks the written bytes/header (metadata_compressed_type == kNone, metadata_compressed_size == metadata_original_size) and a successful unpack.
  • Release and ASan ctest pass.

Related: #93, #95.

Activity

  1. added
    enhancement
    on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions