feat: Add zip assertion block for validating zip archive entry existence#47
Conversation
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
…ME table alignment Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
|
@copilot What are your thoughts on this, and do you think it will be easy (in the future) to run the other checks (e.g. PDF, Yaml, Json) on files in the zip - would it need a virtual filesystem interface that could point to the real filesystem or a zip archive? |
Good question. The current design would need some refactoring to support running content checks (PDF, YAML, JSON, etc.) on entries inside a zip. Here's the analysis: Current bottleneck: Every assert type ( Three paths forward, in order of effort:
My recommendation for a future issue: start with option 2 (stream overloads). The individual per-type changes are straightforward and isolated, it handles all the common content check types cleanly, and it doesn't require the full virtual filesystem abstraction unless nested zip checking (zip-within-zip) becomes a requirement. |
There was a problem hiding this comment.
Pull request overview
Adds first-class zip archive entry assertions to FileAssert’s per-file checks, enabling validation that an archive contains expected entries via glob patterns and optional min/max match counts.
Changes:
- Introduces a new
zip:assertion block (DTO + modeling unit) that opens a zip and matches entry names withMicrosoft.Extensions.FileSystemGlobbing. - Wires the new zip assert into
FileAssertFileexecution and updates README acceptance criteria + examples. - Adds unit tests and ReqStream/design/verification documentation (including
.reviewmark.yamlcoverage).
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/DemaConsulting.FileAssert.Tests/Modeling/FileAssertZipAssertTests.cs | New unit tests for zip entry matching, bounds checking, and invalid/missing zip error paths. |
| src/DemaConsulting.FileAssert/Modeling/FileAssertZipAssert.cs | New zip-assert implementation: open zip, normalize entry names, glob match, enforce min/max. |
| src/DemaConsulting.FileAssert/Modeling/FileAssertFile.cs | Integrates zip: block into file-level assertion creation and per-file execution pipeline. |
| src/DemaConsulting.FileAssert/Configuration/FileAssertData.cs | Adds YAML DTOs for zip: configuration (FileAssertZipData, FileAssertZipEntryData). |
| requirements.yaml | Includes the new ReqStream unit requirements file for the zip assert unit. |
| README.md | Documents the zip: assertion block in examples and the acceptance-criteria reference table. |
| docs/verification/file-assert/modeling/file-assert-zip-assert.md | Unit-level verification design and scenario coverage for FileAssertZipAssert. |
| docs/verification/file-assert/modeling.md | Adds zip-assert test coverage references to modeling subsystem verification. |
| docs/verification/file-assert.md | Adds system-level verification scenarios/coverage references for zip assertions. |
| docs/reqstream/file-assert/modeling/file-assert-zip-assert.yaml | New unit requirements for zip assert creation, entry matching, and parse errors. |
| docs/reqstream/file-assert/modeling.yaml | Links zip assert requirements into Modeling subsystem requirement tree. |
| docs/reqstream/file-assert.yaml | Adds system requirement for zip archive assertions and links children/tests. |
| docs/design/introduction.md | Adds FileAssertZipAssert to the design introduction unit inventory. |
| docs/design/file-assert/modeling/file-assert-zip-assert.md | Design doc for the new zip assert unit (behavior, YAML shape, errors). |
| docs/design/file-assert/modeling.md | Adds zip assert to modeling subsystem design overview and hierarchy. |
| docs/design/file-assert.md | Updates system design flow to include zip assertion execution path. |
| .reviewmark.yaml | Adds the required per-unit review-set entry for the new modeling unit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot apply changes based on the comments in this thread |
Done. The code and all documentation were already using |
Pull Request
Description
Adds a
zip:assertion block enabling FileAssert to validate that zip archives (including.nupkg,.jar, etc.) contain expected entries, with optional min/max count constraints and glob pattern matching.New block:
zip:Entry paths are normalized to forward slashes before matching; glob patterns are resolved via
Microsoft.Extensions.FileSystemGlobbing(same mechanism asFileAssertFile). No new NuGet dependencies — usesSystem.IO.Compressionfrom the BCL.Changes
Modeling/FileAssertZipAssert.cs— new zip assert unit; opens zip viaZipFile.OpenRead, collects all entry names, appliesMatcherper pattern, enforces min/maxConfiguration/FileAssertData.cs— newFileAssertZipEntryDataandFileAssertZipDataDTOsModeling/FileAssertFile.cs— wires thezip:block into the per-file assertion pipelineREADME.md— documents newzip:block with YAML examples and acceptance criteria table entriesdocs/;introduction.mdand.reviewmark.yamlupdated to include the new unitType of Change
Related Issues
Pre-Submission Checklist
Before submitting this pull request, ensure you have completed the following:
Build and Test
pwsh ./build.ps1Code Quality
Quality Checks
Please run the following checks before submitting:
pwsh ./lint.ps1Testing
Documentation
Additional Notes
The
zip:block intentionally checks only entry existence. Recursive content inspection of zip entries (text/HTML/JSON/etc.) is explicitly deferred — it would require abstracting the file-system interface used by existing rules. A future enhancement could support content checks on matched entries via stream-based overloads on each assert type (all relevant OTS libraries support stream/byte-array loading), or a full virtual filesystem abstraction for nested zip-in-zip scenarios.