1+ /// MacDive real-sample regression suite.
2+ ///
3+ /// These tests exercise a real MacDive UDDF export that is not checked into
4+ /// the repository. To run them locally, point the [MACDIVE_UDDF_SAMPLE]
5+ /// compile-time environment variable at your local sample file:
6+ ///
7+ /// flutter test \
8+ /// --dart-define=MACDIVE_UDDF_SAMPLE=/absolute/path/to/sample.uddf \
9+ /// --run-skipped --tags=real-data \
10+ /// test/core/services/export/uddf/uddf_macdive_real_sample_test.dart
11+ ///
12+ /// Without the env var (or when the file at that path does not exist), every
13+ /// test in this suite is cleanly skipped so CI and fresh clones stay green.
114@Tags (['real-data' ])
215library ;
316
@@ -6,30 +19,49 @@ import 'dart:io';
619import 'package:flutter_test/flutter_test.dart' ;
720import 'package:submersion/core/services/export/uddf/uddf_full_import_service.dart' ;
821
9- const _realSamplePath =
10- '/Users/ericgriffin/Documents/submersion development/submersion data/Macdive/Apr 4 no iPad sync.uddf' ;
22+ /// Compile-time env var that points at a local MacDive UDDF sample.
23+ ///
24+ /// Injected via `flutter test --dart-define=MACDIVE_UDDF_SAMPLE=...` .
25+ const _realSamplePathEnvVar = String .fromEnvironment ('MACDIVE_UDDF_SAMPLE' );
26+
27+ String ? _realSamplePath () {
28+ if (_realSamplePathEnvVar.isEmpty) return null ;
29+ return _realSamplePathEnvVar;
30+ }
1131
1232void main () {
1333 group ('MacDive real-sample regression' , () {
1434 late UddfFullImportService service;
1535 late String content;
36+ var hasFixture = false ;
1637
1738 setUpAll (() async {
18- final file = File (_realSamplePath);
19- if (! file.existsSync ()) {
20- markTestSkipped ('Real sample not available in this environment' );
21- return ;
22- }
39+ final path = _realSamplePath ();
40+ if (path == null ) return ;
41+ final file = File (path);
42+ if (! file.existsSync ()) return ;
2343 content = await file.readAsString ();
2444 service = UddfFullImportService ();
45+ hasFixture = true ;
2546 });
2647
48+ bool skipIfNoFixture () {
49+ if (hasFixture) return false ;
50+ markTestSkipped (
51+ 'Real sample not available. Set MACDIVE_UDDF_SAMPLE via '
52+ '--dart-define and pass --run-skipped --tags=real-data to run.' ,
53+ );
54+ return true ;
55+ }
56+
2757 test ('parses 540 dives' , () async {
58+ if (skipIfNoFixture ()) return ;
2859 final result = await service.importAllDataFromUddf (content);
2960 expect (result.dives.length, 540 );
3061 });
3162
3263 test ('every dive has a sourceUuid from <dive id>' , () async {
64+ if (skipIfNoFixture ()) return ;
3365 final result = await service.importAllDataFromUddf (content);
3466 expect (
3567 result.dives.every ((d) => d['sourceUuid' ] is String ),
@@ -39,18 +71,21 @@ void main() {
3971 });
4072
4173 test ('parses at least 350 sites' , () async {
74+ if (skipIfNoFixture ()) return ;
4275 final result = await service.importAllDataFromUddf (content);
4376 expect (result.sites.length, greaterThanOrEqualTo (350 ));
4477 });
4578
4679 test ('parses at least 30 buddies' , () async {
80+ if (skipIfNoFixture ()) return ;
4781 final result = await service.importAllDataFromUddf (content);
4882 expect (result.buddies.length, greaterThanOrEqualTo (30 ));
4983 });
5084
5185 test (
5286 'parses at least 20 gear items from <diver><owner><equipment>' ,
5387 () async {
88+ if (skipIfNoFixture ()) return ;
5489 final result = await service.importAllDataFromUddf (content);
5590 expect (
5691 result.equipment.length,
@@ -61,6 +96,7 @@ void main() {
6196 );
6297
6398 test ('at least one dive has equipmentRefs populated' , () async {
99+ if (skipIfNoFixture ()) return ;
64100 final result = await service.importAllDataFromUddf (content);
65101 final withGear = result.dives.where (
66102 (d) => (d['equipmentRefs' ] as List ? )? .isNotEmpty ?? false ,
@@ -73,6 +109,7 @@ void main() {
73109 });
74110
75111 test ('at least one dive has gas-switch markers' , () async {
112+ if (skipIfNoFixture ()) return ;
76113 final result = await service.importAllDataFromUddf (content);
77114 final withSwitch = result.dives.where ((d) {
78115 final profile = d['profile' ] as List ? ;
@@ -87,6 +124,7 @@ void main() {
87124 });
88125
89126 test ('at least one site has country populated' , () async {
127+ if (skipIfNoFixture ()) return ;
90128 final result = await service.importAllDataFromUddf (content);
91129 final withCountry = result.sites.where (
92130 (s) => (s['country' ] as String ? )? .isNotEmpty ?? false ,
0 commit comments