You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dateKeys-dart/test/testdata_test.dart

47 lines
1.6 KiB

// 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<File>();
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<String, Object?> && 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));
});
}

Powered by TurnKey Linux.