feat: remote manifest model and content dependencies

Add http, crypto, path_provider deps; introduce RemoteManifest /
ManifestSeason immutable models with fromJson/toJson, schema-version
guard (FormatException on unsupported schema), and fallback for missing
current field. 3/3 TDD tests pass, flutter analyze clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 13:02:17 +09:00
parent 63ac8c6b9e
commit c7bdb9b9c9
4 changed files with 127 additions and 3 deletions
+50
View File
@@ -0,0 +1,50 @@
import 'package:block_seasons/data/remote/manifest.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
final json = {
'schemaVersion': 1,
'minAppBuild': 1,
'current': 'season_002',
'seasons': [
{
'seasonId': 'season_001',
'version': 1,
'packUrl': 'seasons/season_001/pack.json',
'sha256': 'abc123',
},
{
'seasonId': 'season_002',
'version': 3,
'packUrl': 'seasons/season_002/pack.json',
'sha256': 'def456',
},
],
};
test('round-trips through json', () {
final manifest = RemoteManifest.fromJson(json);
expect(manifest.schemaVersion, 1);
expect(manifest.minAppBuild, 1);
expect(manifest.current, 'season_002');
expect(manifest.seasons, hasLength(2));
expect(manifest.seasons[1].seasonId, 'season_002');
expect(manifest.seasons[1].version, 3);
expect(manifest.seasons[1].packUrl, 'seasons/season_002/pack.json');
expect(manifest.seasons[1].sha256, 'def456');
expect(RemoteManifest.fromJson(manifest.toJson()).toJson(),
manifest.toJson());
});
test('rejects unsupported schema', () {
expect(
() => RemoteManifest.fromJson({...json, 'schemaVersion': 99}),
throwsFormatException,
);
});
test('missing current falls back to last season id', () {
final m = RemoteManifest.fromJson({...json}..remove('current'));
expect(m.current, 'season_002');
});
}