Skip to content

chore: remove BlobPathStrings helper#90

Merged
woutervanranst merged 2 commits into
masterfrom
remove-blobpathstrings
May 12, 2026
Merged

chore: remove BlobPathStrings helper#90
woutervanranst merged 2 commits into
masterfrom
remove-blobpathstrings

Conversation

@woutervanranst

@woutervanranst woutervanranst commented May 12, 2026

Copy link
Copy Markdown
Owner

Use BlobPaths directly in tests so blob names stay strongly typed and the obsolete string wrapper cannot drift from production paths.

Summary by CodeRabbit

  • Tests

    • Updated test infrastructure across multiple test suites to use improved blob path helpers, ensuring consistent path handling.
    • Added architecture validation to prevent deprecated test utilities from being reintroduced.
  • Chores

    • Removed outdated test helper class, consolidating blob path functionality into more robust utilities.

Use BlobPaths directly in tests so blob names stay strongly typed and the obsolete string wrapper cannot drift from production paths.
@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR migrates test blob path construction from the BlobPathStrings string helper class to typed BlobPaths methods. The fake metadata blob service is updated to key metadata with RelativePath instead of string, all test files are updated to use the new helpers, and the old helper class is removed with an architecture test enforcing its absence.

Changes

Test Blob Path Helper Migration

Layer / File(s) Summary
Metadata storage type migration
src/Arius.Core.Tests/Fakes/FakeMetadataOnlyBlobContainerService.cs
The Metadata dictionary switches from string keys (with ordinal comparison) to RelativePath keys. GetMetadataAsync now queries metadata directly using the RelativePath argument without intermediate string conversion.
Test blob path updates
src/Arius.Core.Tests/Features/ArchiveCommand/ArchiveRecoveryTests.cs, src/Arius.Core.Tests/Features/ChunkHydrationStatusQuery/ResolveFileHydrationStatusesHandlerTests.cs, src/Arius.Core.Tests/Features/ListQuery/ListQueryHandlerTests.cs, src/Arius.Core.Tests/Features/RestoreCommand/RestoreCommandHandlerTests.cs, src/Arius.Core.Tests/Shared/ChunkStorage/ChunkStorageHydrationStatusTests.cs, src/Arius.Core.Tests/Shared/ChunkStorage/ChunkStorageServiceReadTests.cs, src/Arius.Core.Tests/Shared/ChunkStorage/ChunkStorageServiceUploadTests.cs, src/Arius.Core.Tests/Shared/FileTree/FileTreeServiceTests.cs
Across 8 test files, blob path construction is updated to use BlobPaths.*Path(...) methods instead of BlobPathStrings.* helpers for chunk, thin chunk, rehydrated, file tree, and snapshot paths. Metadata keys in fake blob containers and test setup match the new typed BlobPaths format. All test expectations and assertions remain unchanged.
Old helper removal and architecture validation
src/Arius.Tests.Shared/BlobPathStrings.cs, src/Arius.Architecture.Tests/DependencyTests.cs
The BlobPathStrings class (exposing Chunk, ThinChunk, ChunkRehydrated, FileTree, Snapshot, ChunkIndexShard static helpers) is deleted. A new architecture test in DependencyTests (TestsShared_Should_Not_Define_BlobPathStrings_Helper) uses a RepositoryRoot constant to verify the file does not exist, preventing re-introduction of the obsolete helper.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • woutervanranst/Arius7#56: Both PRs replace BlobPathStrings usages with BlobPaths and refactor blob path helpers and test infrastructure around typed path representations.
  • woutervanranst/Arius7#69: Both PRs remove string-based blob path helpers and migrate tests to use typed BlobPaths with strong hash types.
  • woutervanranst/Arius7#89: Both PRs update blob-path helper usage in tests, shifting away from BlobPathStrings and toward the typed BlobPaths infrastructure.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: remove BlobPathStrings helper' directly and concisely describes the main change—removing the BlobPathStrings utility class and replacing it with direct BlobPaths usage throughout the test files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch remove-blobpathstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Arius.Architecture.Tests/DependencyTests.cs`:
- Line 17: The hard-coded upward Path.Combine chain used to initialize
RepositoryRoot from AppContext.BaseDirectory is brittle; replace it with a
deterministic repo-root discovery routine: implement a FindRepositoryRoot method
that walks parent directories from AppContext.BaseDirectory and returns the
first directory containing a repo marker (for example a .git folder or the
solution file or the known file BlobPathStrings.cs), use that method to set
RepositoryRoot and to compute helperPath (and update the checks around
helperPath/BlobPathStrings.cs referenced on lines ~146-148) and make the test
fail loudly if no repo marker is found instead of proceeding with a wrong path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dbba7058-b8a7-4003-b4e5-97c2c0ed13a6

📥 Commits

Reviewing files that changed from the base of the PR and between 73982a1 and e2a5996.

📒 Files selected for processing (11)
  • src/Arius.Architecture.Tests/DependencyTests.cs
  • src/Arius.Core.Tests/Fakes/FakeMetadataOnlyBlobContainerService.cs
  • src/Arius.Core.Tests/Features/ArchiveCommand/ArchiveRecoveryTests.cs
  • src/Arius.Core.Tests/Features/ChunkHydrationStatusQuery/ResolveFileHydrationStatusesHandlerTests.cs
  • src/Arius.Core.Tests/Features/ListQuery/ListQueryHandlerTests.cs
  • src/Arius.Core.Tests/Features/RestoreCommand/RestoreCommandHandlerTests.cs
  • src/Arius.Core.Tests/Shared/ChunkStorage/ChunkStorageHydrationStatusTests.cs
  • src/Arius.Core.Tests/Shared/ChunkStorage/ChunkStorageServiceReadTests.cs
  • src/Arius.Core.Tests/Shared/ChunkStorage/ChunkStorageServiceUploadTests.cs
  • src/Arius.Core.Tests/Shared/FileTree/FileTreeServiceTests.cs
  • src/Arius.Tests.Shared/BlobPathStrings.cs
💤 Files with no reviewable changes (1)
  • src/Arius.Tests.Shared/BlobPathStrings.cs

/// </summary>
public class DependencyTests
{
private static readonly string RepositoryRoot = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", ".."));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Repository root discovery is brittle and can produce false-green test results.

Using a fixed .. depth from AppContext.BaseDirectory is environment-dependent; if output layout changes, helperPath can point to the wrong location and the test may pass even when BlobPathStrings.cs exists.

💡 Proposed fix
-    private static readonly string RepositoryRoot = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", ".."));
+    private static readonly string RepositoryRoot = ResolveRepositoryRoot();
+
+    private static string ResolveRepositoryRoot()
+    {
+        var dir = new DirectoryInfo(AppContext.BaseDirectory);
+        while (dir is not null)
+        {
+            var testsSharedDir = Path.Combine(dir.FullName, "src", "Arius.Tests.Shared");
+            if (Directory.Exists(testsSharedDir))
+                return dir.FullName;
+
+            dir = dir.Parent;
+        }
+
+        throw new DirectoryNotFoundException(
+            $"Could not resolve repository root from '{AppContext.BaseDirectory}'.");
+    }

Also applies to: 146-148

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Arius.Architecture.Tests/DependencyTests.cs` at line 17, The hard-coded
upward Path.Combine chain used to initialize RepositoryRoot from
AppContext.BaseDirectory is brittle; replace it with a deterministic repo-root
discovery routine: implement a FindRepositoryRoot method that walks parent
directories from AppContext.BaseDirectory and returns the first directory
containing a repo marker (for example a .git folder or the solution file or the
known file BlobPathStrings.cs), use that method to set RepositoryRoot and to
compute helperPath (and update the checks around helperPath/BlobPathStrings.cs
referenced on lines ~146-148) and make the test fail loudly if no repo marker is
found instead of proceeding with a wrong path.

@codecov

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.77%. Comparing base (7e2bc27) to head (7206122).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #90   +/-   ##
=======================================
  Coverage   78.77%   78.77%           
=======================================
  Files          78       78           
  Lines        5277     5277           
  Branches      722      722           
=======================================
  Hits         4157     4157           
+ Misses        929      928    -1     
- Partials      191      192    +1     
Flag Coverage Δ
linux 81.93% <ø> (ø)
windows 77.12% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@woutervanranst woutervanranst merged commit 0447b29 into master May 12, 2026
12 checks passed
@woutervanranst woutervanranst deleted the remove-blobpathstrings branch May 12, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant