// The tests run whatever testdata/ holds, so the shared Go vectors are only as // good as their integrity: a truncated or edited file must fail here rather // than pass with fewer cases. The check is the one of tool/sync_testdata.dart: // every file matches the SHA-256 recorded in testdata/SOURCE.json for the // pinned datekeys-go commit, with none missing and none extra. And every file // names the specification that this package implements. @TestOn('vm') library; import 'dart:convert'; import 'dart:io'; import 'package:datekeys/datekeys.dart'; import 'package:test/test.dart'; import '../tool/sync_testdata.dart' as testdata; void main() { final root = Directory.current; test('testdata/ matches SOURCE.json byte for byte, with no missing or extra file', () { final r = testdata.check(root); expect(r.errors, isEmpty); expect(r.module, testdata.module); expect(r.commit, matches(RegExp(r'^[0-9a-f]{40}$'))); expect(r.files, greaterThan(100)); }); test('every JSON of testdata/ with a spec field names specVersion', () { var named = 0; final files = Directory('${root.path}/testdata') .listSync(recursive: true) .whereType(); for (final f in files.where( (f) => f.path.endsWith('.json') && !f.path.endsWith('SOURCE.json'), )) { final json = jsonDecode(f.readAsStringSync()); if (json is Map && json.containsKey('spec')) { expect(json['spec'], specVersion, reason: f.path); named++; } } // The vectors and the record of every fixture carry it. expect(named, greaterThan(40)); }); }