Skip to content

Data Migration: add UnsupportedVersion and ChecksumMismatch error-path tests for all import_from_* paths#746

Merged
Baskarayelu merged 3 commits into
Remitwise-Org:mainfrom
Menjay7:jay
Jun 18, 2026
Merged

Data Migration: add UnsupportedVersion and ChecksumMismatch error-path tests for all import_from_* paths#746
Baskarayelu merged 3 commits into
Remitwise-Org:mainfrom
Menjay7:jay

Conversation

@Menjay7

@Menjay7 Menjay7 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Add comprehensive error-path test coverage for all import_from_* migration entry points, ensuring imports correctly fail with UnsupportedVersion and ChecksumMismatch errors when encountering incompatible or corrupted data.

These tests validate that migration imports fail safely, consistently, and predictably across every supported import source.

Problem

Current migration tests primarily focus on successful import scenarios and do not fully verify failure handling:

Unsupported data versions may not be consistently rejected.
Corrupted imports with invalid checksums are not comprehensively tested.
Error handling behavior may differ across import_from_* implementations.
Future changes could accidentally bypass validation checks or alter error semantics.
Corrupted or incompatible data could lead to partial imports or inconsistent state.
Solution

Introduce a shared test suite that exercises UnsupportedVersion and ChecksumMismatch failure paths for every import_from_* implementation.

Covered Import Paths

Tests are added for all migration entry points, including:

import_from_file(...)
import_from_bytes(...)
import_from_json(...)
import_from_backup(...)
...all other import_from_* variants
Error Scenarios
Unsupported Version

Verify imports fail when the payload version is newer, older, or otherwise incompatible.

Import Payload
├── version = current → Accepted
├── version = unsupported → UnsupportedVersion
└── version = malformed → UnsupportedVersion
Checksum Mismatch

Verify imports fail when payload integrity validation fails.

Payload Data
├── Valid checksum → Imported successfully
├── Modified payload → ChecksumMismatch
└── Corrupted checksum → ChecksumMismatch
Implementation Details

Added tests that:

Generate fixtures with unsupported schema versions.
Generate corrupted payloads with invalid checksums.
Execute every import_from_* path using identical failure scenarios.
Assert that imports return the expected error variants.
Verify imports abort before any state mutation occurs.
Ensure behavior remains deterministic across repeated executions.
Example Assertions
assert_eq!(
result,
Err(MigrationError::UnsupportedVersion)
);

assert_eq!(
result,
Err(MigrationError::ChecksumMismatch)
);
State Integrity Verification

Tests additionally confirm that:

No partial data is imported.
Existing state remains unchanged after failures.
Temporary resources are cleaned up correctly.
Validation failures do not leave migration artifacts behind.
Edge Cases Covered
Version greater than supported maximum.
Version lower than minimum supported version.
Missing version metadata.
Corrupted checksum field.
Tampered payload contents.
Empty payloads with invalid checksums.
Large import payloads with integrity failures.
Multiple consecutive failed import attempts.
Testing Benefits
Ensures all import implementations enforce version compatibility.
Guarantees corrupted data is rejected consistently.
Prevents regressions in migration validation logic.
Protects application state from partial or unsafe imports.
Provides uniform error semantics across all import entry points.
Breaking Changes

None.

This PR adds automated test coverage only and does not modify migration runtime behavior.. Closed #730

@Baskarayelu Baskarayelu merged commit 2cf322e into Remitwise-Org:main Jun 18, 2026
4 of 12 checks passed
@Baskarayelu

Copy link
Copy Markdown
Contributor

rebased onto main and resolved a small additive conflict in data_migration. good error-path coverage on the UnsupportedVersion / ChecksumMismatch import paths - those were exactly the untested branches. merged 👍

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.

Data Migration: add UnsupportedVersion and ChecksumMismatch error-path tests for all import_from_* paths

3 participants